test_Controller.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import unittest
  2. import unittest.mock as mock
  3. import Core.Controller as Ctrl
  4. class TestController(unittest.TestCase):
  5. @mock.patch("builtins.print")
  6. def test_process_help(self, mock_print):
  7. Ctrl.Controller.process_help(None)
  8. self.assertTrue(mock_print.called)
  9. @mock.patch("builtins.print")
  10. def test_process_help_most_used(self, mock_print):
  11. Ctrl.Controller.process_help(["most_used"])
  12. self.assertTrue(mock_print.called)
  13. @mock.patch("builtins.print")
  14. def test_process_help_least_used(self, mock_print):
  15. Ctrl.Controller.process_help(["least_used"])
  16. self.assertTrue(mock_print.called)
  17. @mock.patch("builtins.print")
  18. def test_process_help_avg(self, mock_print):
  19. Ctrl.Controller.process_help(["avg"])
  20. self.assertTrue(mock_print.called)
  21. @mock.patch("builtins.print")
  22. def test_process_help_all(self, mock_print):
  23. Ctrl.Controller.process_help(["all"])
  24. self.assertTrue(mock_print.called)
  25. @mock.patch("builtins.print")
  26. def test_process_help_random(self, mock_print):
  27. Ctrl.Controller.process_help(["random"])
  28. self.assertTrue(mock_print.called)
  29. @mock.patch("builtins.print")
  30. def test_process_help_first(self, mock_print):
  31. Ctrl.Controller.process_help(["first"])
  32. self.assertTrue(mock_print.called)
  33. @mock.patch("builtins.print")
  34. def test_process_help_last(self, mock_print):
  35. Ctrl.Controller.process_help(["last"])
  36. self.assertTrue(mock_print.called)
  37. @mock.patch("builtins.print")
  38. def test_process_help_ipaddress(self, mock_print):
  39. Ctrl.Controller.process_help(["ipaddress"])
  40. self.assertTrue(mock_print.called)
  41. @mock.patch("builtins.print")
  42. def test_process_help_macaddress(self, mock_print):
  43. Ctrl.Controller.process_help(["macaddress"])
  44. self.assertTrue(mock_print.called)
  45. @mock.patch("builtins.print")
  46. def test_process_help_examples(self, mock_print):
  47. Ctrl.Controller.process_help(["examples"])
  48. self.assertTrue(mock_print.called)
  49. @mock.patch("builtins.print")
  50. def test_process_help_invalid(self, mock_print):
  51. Ctrl.Controller.process_help(["invalid_keyword"])
  52. self.assertTrue(mock_print.called)
  53. self.assertEqual(mock_print.call_count, 2)
  54. self.assertEqual(mock_print.call_args_list[0][0][0],
  55. "Unknown keyword 'invalid_keyword', try 'help;' to get a list of allowed keywords'")