1
0

test_modjk.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Libs
  8. import salt.states.modjk as modjk
  9. from salt.ext import six
  10. # Import Salt Testing Libs
  11. from tests.support.unit import TestCase
  12. if six.PY2:
  13. LIST_NOT_STR = "workers should be a list not a <type 'unicode'>"
  14. else:
  15. LIST_NOT_STR = "workers should be a list not a <class 'str'>"
  16. class ModjkTestCase(TestCase):
  17. """
  18. Test cases for salt.states.modjk
  19. """
  20. # 'worker_stopped' function tests: 1
  21. def test_worker_stopped(self):
  22. """
  23. Test to stop all the workers in the modjk load balancer
  24. """
  25. name = "loadbalancer"
  26. ret = {"name": name, "result": False, "comment": "", "changes": {}}
  27. ret.update({"comment": LIST_NOT_STR})
  28. self.assertDictEqual(modjk.worker_stopped(name, "app1"), ret)
  29. # 'worker_activated' function tests: 1
  30. def test_worker_activated(self):
  31. """
  32. Test to activate all the workers in the modjk load balancer
  33. """
  34. name = "loadbalancer"
  35. ret = {"name": name, "result": False, "comment": "", "changes": {}}
  36. ret.update({"comment": LIST_NOT_STR})
  37. self.assertDictEqual(modjk.worker_activated(name, "app1"), ret)
  38. # 'worker_disabled' function tests: 1
  39. def test_worker_disabled(self):
  40. """
  41. Test to disable all the workers in the modjk load balancer
  42. """
  43. name = "loadbalancer"
  44. ret = {"name": name, "result": False, "comment": "", "changes": {}}
  45. ret.update({"comment": LIST_NOT_STR})
  46. self.assertDictEqual(modjk.worker_disabled(name, "app1"), ret)
  47. # 'worker_recover' function tests: 1
  48. def test_worker_recover(self):
  49. """
  50. Test to recover all the workers in the modjk load balancer
  51. """
  52. name = "loadbalancer"
  53. ret = {"name": name, "result": False, "comment": "", "changes": {}}
  54. ret.update({"comment": LIST_NOT_STR})
  55. self.assertDictEqual(modjk.worker_recover(name, "app1"), ret)