mirror of
https://github.com/munki/munki.git
synced 2026-04-24 22:08:33 -05:00
Get tests working in this branch
This commit is contained in:
+26
-26
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
# encoding: utf-8
|
||||
"""
|
||||
munkicommon_display_unicode_test.py
|
||||
test_display_unicode.py
|
||||
|
||||
Unit tests for munkicommon's display_* functions.
|
||||
Unit tests for display.display_* functions.
|
||||
|
||||
"""
|
||||
# Copyright 2014-2016 Greg Neagle.
|
||||
@@ -21,7 +21,7 @@ Unit tests for munkicommon's display_* functions.
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import code.client.munkilib.munkicommon as munkicommon
|
||||
import munkilib.display as display
|
||||
import unittest
|
||||
|
||||
|
||||
@@ -33,79 +33,79 @@ ARG_STR = 'Günther'
|
||||
|
||||
|
||||
def log(msg, logname=''):
|
||||
"""Redefine munkicommon's logging function so our tests don't write
|
||||
"""Redefine the logging function so our tests don't write
|
||||
a bunch of garbage to Munki's logs"""
|
||||
pass
|
||||
munkicommon.log = log
|
||||
display.munkilog.log = log
|
||||
|
||||
|
||||
class TestDisplayInfoUnicodeOutput(unittest.TestCase):
|
||||
"""Test munkicommon display_info with text that may or may not be proper
|
||||
"""Test display_info with text that may or may not be proper
|
||||
Unicode."""
|
||||
|
||||
def test_display_info_with_unicode_msg(self):
|
||||
munkicommon.display_info(MSG_UNI)
|
||||
display.display_info(MSG_UNI)
|
||||
|
||||
def test_display_info_with_str_msg(self):
|
||||
munkicommon.display_info(MSG_STR)
|
||||
display.display_info(MSG_STR)
|
||||
|
||||
def test_display_info_with_unicode_msg_unicode_arg(self):
|
||||
munkicommon.display_info(MSG_UNI, ARG_UNI)
|
||||
display.display_info(MSG_UNI, ARG_UNI)
|
||||
|
||||
def test_display_info_with_unicode_msg_str_arg(self):
|
||||
munkicommon.display_info(MSG_UNI, ARG_STR)
|
||||
display.display_info(MSG_UNI, ARG_STR)
|
||||
|
||||
def test_display_info_with_str_msg_unicode_arg(self):
|
||||
munkicommon.display_info(MSG_STR, ARG_UNI)
|
||||
display.display_info(MSG_STR, ARG_UNI)
|
||||
|
||||
def test_display_info_with_str_msg_str_arg(self):
|
||||
munkicommon.display_info(MSG_STR, ARG_STR)
|
||||
display.display_info(MSG_STR, ARG_STR)
|
||||
|
||||
|
||||
class TestDisplayWarningUnicodeOutput(unittest.TestCase):
|
||||
"""Test munkicommon display_warning with text that may or may not be proper
|
||||
"""Test display_warning with text that may or may not be proper
|
||||
Unicode."""
|
||||
|
||||
def test_display_warning_with_unicode_msg(self):
|
||||
munkicommon.display_warning(MSG_UNI)
|
||||
display.display_warning(MSG_UNI)
|
||||
|
||||
def test_display_warning_with_str_msg(self):
|
||||
munkicommon.display_warning(MSG_STR)
|
||||
display.display_warning(MSG_STR)
|
||||
|
||||
def test_display_warning_with_unicode_msg_unicode_arg(self):
|
||||
munkicommon.display_warning(MSG_UNI, ARG_UNI)
|
||||
display.display_warning(MSG_UNI, ARG_UNI)
|
||||
|
||||
def test_display_warning_with_unicode_msg_str_arg(self):
|
||||
munkicommon.display_warning(MSG_UNI, ARG_STR)
|
||||
display.display_warning(MSG_UNI, ARG_STR)
|
||||
|
||||
def test_display_warning_with_str_msg_unicode_arg(self):
|
||||
munkicommon.display_warning(MSG_STR, ARG_UNI)
|
||||
display.display_warning(MSG_STR, ARG_UNI)
|
||||
|
||||
def test_display_warning_with_str_msg_str_arg(self):
|
||||
munkicommon.display_warning(MSG_STR, ARG_STR)
|
||||
display.display_warning(MSG_STR, ARG_STR)
|
||||
|
||||
|
||||
class TestDisplayErrorUnicodeOutput(unittest.TestCase):
|
||||
"""Test munkicommon display_error with text that may or may not be proper
|
||||
"""Test display_error with text that may or may not be proper
|
||||
Unicode."""
|
||||
|
||||
def test_display_error_with_unicode_msg(self):
|
||||
munkicommon.display_error(MSG_UNI)
|
||||
display.display_error(MSG_UNI)
|
||||
|
||||
def test_display_error_with_str_msg(self):
|
||||
munkicommon.display_error(MSG_STR)
|
||||
display.display_error(MSG_STR)
|
||||
|
||||
def test_display_error_with_unicode_msg_unicode_arg(self):
|
||||
munkicommon.display_error(MSG_UNI, ARG_UNI)
|
||||
display.display_error(MSG_UNI, ARG_UNI)
|
||||
|
||||
def test_display_error_with_unicode_msg_str_arg(self):
|
||||
munkicommon.display_error(MSG_UNI, ARG_STR)
|
||||
display.display_error(MSG_UNI, ARG_STR)
|
||||
|
||||
def test_display_error_with_str_msg_unicode_arg(self):
|
||||
munkicommon.display_error(MSG_STR, ARG_UNI)
|
||||
display.display_error(MSG_STR, ARG_UNI)
|
||||
|
||||
def test_display_error_with_str_msg_str_arg(self):
|
||||
munkicommon.display_error(MSG_STR, ARG_STR)
|
||||
display.display_error(MSG_STR, ARG_STR)
|
||||
|
||||
|
||||
def main():
|
||||
Regular → Executable
+19
-19
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
# encoding: utf-8
|
||||
"""
|
||||
munkicommon_display_unicode_test.py
|
||||
test_isapprunning.py
|
||||
|
||||
Unit tests for munkicommon's display_* functions.
|
||||
Unit tests for processes.isAppRunning.
|
||||
|
||||
"""
|
||||
# Copyright 2016-present Nate Walck.
|
||||
@@ -21,7 +21,7 @@ Unit tests for munkicommon's display_* functions.
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import code.client.munkilib.munkicommon as munkicommon
|
||||
from munkilib import processes
|
||||
import unittest
|
||||
from data_scaffolds import getRunningProcessesMock
|
||||
|
||||
@@ -42,67 +42,67 @@ class TestIsAppRunning(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
self.processes = []
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_with_exact_path_match(self, ps_mock):
|
||||
print("Testing isAppRunning with exact path match...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('/Applications/Firefox.app/Contents/MacOS/firefox'),
|
||||
processes.isAppRunning('/Applications/Firefox.app/Contents/MacOS/firefox'),
|
||||
True
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_with_exact_path_no_match(self, ps_mock):
|
||||
print("Testing isAppRunning with exact path no matches...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('/usr/local/bin/bonzi'),
|
||||
processes.isAppRunning('/usr/local/bin/bonzi'),
|
||||
False
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_by_filename_match(self, ps_mock):
|
||||
print("Testing isAppRunning with file name match...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('Firefox.app'),
|
||||
processes.isAppRunning('Firefox.app'),
|
||||
True
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_by_filename_no_match(self, ps_mock):
|
||||
print("Testing isAppRunning with file name no matches...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('BonziBUDDY.app'),
|
||||
processes.isAppRunning('BonziBUDDY.app'),
|
||||
False
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_by_executable_name_match(self, ps_mock):
|
||||
print("Testing isAppRunning with executable name match...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('firefox'),
|
||||
processes.isAppRunning('firefox'),
|
||||
True
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_by_executable_name_no_match(self, ps_mock):
|
||||
print("Testing isAppRunning with executable name no matches...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('bonzi'),
|
||||
processes.isAppRunning('bonzi'),
|
||||
False
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_name_with_dot_app_match(self, ps_mock):
|
||||
print("Testing isAppRunning with name plus .app match...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('Firefox'),
|
||||
processes.isAppRunning('Firefox'),
|
||||
True
|
||||
)
|
||||
|
||||
@patch('code.client.munkilib.munkicommon.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
@patch('munkilib.processes.getRunningProcesses', return_value=getRunningProcessesMock())
|
||||
def test_app_name_with_dot_app_no_match(self, ps_mock):
|
||||
print("Testing isAppRunning with name plus .app match...")
|
||||
self.assertEqual(
|
||||
munkicommon.isAppRunning('BonziBUDDY'),
|
||||
processes.isAppRunning('BonziBUDDY'),
|
||||
False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user