1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import unittest
- import unittest.mock as mock
- import Core.Controller as Ctrl
- class TestController(unittest.TestCase):
- @mock.patch("builtins.print")
- def test_process_help(self, mock_print):
- Ctrl.Controller.process_help(None)
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_most_used(self, mock_print):
- Ctrl.Controller.process_help(["most_used"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_least_used(self, mock_print):
- Ctrl.Controller.process_help(["least_used"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_avg(self, mock_print):
- Ctrl.Controller.process_help(["avg"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_all(self, mock_print):
- Ctrl.Controller.process_help(["all"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_random(self, mock_print):
- Ctrl.Controller.process_help(["random"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_first(self, mock_print):
- Ctrl.Controller.process_help(["first"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_last(self, mock_print):
- Ctrl.Controller.process_help(["last"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_ipaddress(self, mock_print):
- Ctrl.Controller.process_help(["ipaddress"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_macaddress(self, mock_print):
- Ctrl.Controller.process_help(["macaddress"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_examples(self, mock_print):
- Ctrl.Controller.process_help(["examples"])
- self.assertTrue(mock_print.called)
- @mock.patch("builtins.print")
- def test_process_help_invalid(self, mock_print):
- Ctrl.Controller.process_help(["invalid_keyword"])
- self.assertTrue(mock_print.called)
- self.assertEqual(mock_print.call_count, 2)
- self.assertEqual(mock_print.call_args_list[0][0][0],
- "Unknown keyword 'invalid_keyword', try 'help;' to get a list of allowed keywords'")
|