1
0

test_win_task.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- coding: utf-8 -*-
  2. # Import Python Libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Libs
  5. import salt.modules.win_task as win_task
  6. import salt.utils.platform
  7. from tests.support.helpers import destructiveTest
  8. # Import Salt Testing Libs
  9. from tests.support.unit import TestCase, skipIf
  10. @destructiveTest
  11. @skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
  12. class WinTaskTestCase(TestCase):
  13. """
  14. Test cases for salt.modules.win_task
  15. """
  16. def test_repeat_interval(self):
  17. task_name = "SaltTest1"
  18. try:
  19. ret = win_task.create_task(
  20. task_name,
  21. user_name="System",
  22. force=True,
  23. action_type="Execute",
  24. cmd="c:\\salt\\salt-call.bat",
  25. trigger_type="Daily",
  26. trigger_enabled=True,
  27. repeat_duration="30 minutes",
  28. repeat_interval="30 minutes",
  29. )
  30. self.assertTrue(ret)
  31. ret = win_task.info(task_name)
  32. self.assertEqual(ret["triggers"][0]["trigger_type"], "Daily")
  33. finally:
  34. ret = win_task.delete_task(task_name)
  35. self.assertTrue(ret)
  36. def test_repeat_interval_and_indefinitely(self):
  37. task_name = "SaltTest2"
  38. try:
  39. ret = win_task.create_task(
  40. task_name,
  41. user_name="System",
  42. force=True,
  43. action_type="Execute",
  44. cmd="c:\\salt\\salt-call.bat",
  45. trigger_type="Daily",
  46. trigger_enabled=True,
  47. repeat_duration="Indefinitely",
  48. repeat_interval="30 minutes",
  49. )
  50. self.assertTrue(ret)
  51. ret = win_task.info(task_name)
  52. self.assertEqual(ret["triggers"][0]["trigger_type"], "Daily")
  53. finally:
  54. ret = win_task.delete_task(task_name)
  55. self.assertTrue(ret)