test_helpers.py 988 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import
  3. import logging
  4. from tests.unit.utils.scheduler.base import SchedulerTestsBase
  5. log = logging.getLogger(__name__)
  6. class SchedulerHelpersTest(SchedulerTestsBase):
  7. """
  8. Test scheduler helper functions
  9. """
  10. def setUp(self):
  11. super(SchedulerHelpersTest, self).setUp()
  12. self.schedule.opts["loop_interval"] = 1
  13. def test_get_schedule(self):
  14. """
  15. verify that the _get_schedule function works
  16. when remove_hidden is True and schedule data
  17. contains enabled key
  18. """
  19. job_name = "test_get_schedule"
  20. job = {
  21. "schedule": {
  22. "enabled": True,
  23. job_name: {"function": "test.ping", "seconds": 60},
  24. }
  25. }
  26. # Add the job to the scheduler
  27. self.schedule.opts.update(job)
  28. ret = self.schedule._get_schedule(remove_hidden=True)
  29. self.assertEqual(job["schedule"], ret)