Пример #1
0
 def test_get_all(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(
             ref=ResourceReference.to_string_reference(pack=model["pack"], name=model["name"]), trigger=model
         )
     self.assertEqual(len(holder.get_all()), 5)
Пример #2
0
 def test_get_all(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(ref=ResourceReference.to_string_reference(
             pack=model['pack'], name=model['name']),
                            trigger=model)
     self.assertEqual(len(holder.get_all()), 5)
Пример #3
0
 def test_add_trigger(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(
             ref=ResourceReference.to_string_reference(pack=model['pack'], name=model['name']),
             trigger=model
         )
     self.assertEqual(len(holder._timers), 5)
Пример #4
0
 def test_remove_trigger(self):
     holder = TimersHolder()
     model = TestTimersHolder.MODELS.get('cron1.yaml', None)
     self.assertTrue(model is not None)
     ref = ResourceReference.to_string_reference(pack=model['pack'], name=model['name'])
     holder.add_trigger(ref, model)
     self.assertEqual(len(holder._timers), 1)
     holder.remove_trigger(ref, model)
     self.assertEqual(len(holder._timers), 0)
Пример #5
0
 def test_get_all_filters_filter_by_type(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(
             ref=ResourceReference.to_string_reference(pack=model["pack"], name=model["name"]), trigger=model
         )
     self.assertEqual(len(holder.get_all(timer_type=INTERVAL_TIMER_TRIGGER_REF)), 3)
     self.assertEqual(len(holder.get_all(timer_type=DATE_TIMER_TRIGGER_REF)), 1)
     self.assertEqual(len(holder.get_all(timer_type=CRON_TIMER_TRIGGER_REF)), 1)
Пример #6
0
 def test_remove_trigger(self):
     holder = TimersHolder()
     model = TestTimersHolder.MODELS.get("cron1.yaml", None)
     self.assertTrue(model is not None)
     ref = ResourceReference.to_string_reference(pack=model["pack"], name=model["name"])
     holder.add_trigger(ref, model)
     self.assertEqual(len(holder._timers), 1)
     holder.remove_trigger(ref, model)
     self.assertEqual(len(holder._timers), 0)
Пример #7
0
 def test_add_trigger(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(
             ref=ResourceReference.to_string_reference(pack=model["pack"],
                                                       name=model["name"]),
             trigger=model,
         )
     self.assertEqual(len(holder._timers), 5)
Пример #8
0
 def test_get_all_filters_filter_by_type(self):
     holder = TimersHolder()
     for _, model in TestTimersHolder.MODELS.items():
         holder.add_trigger(
             ref=ResourceReference.to_string_reference(pack=model['pack'], name=model['name']),
             trigger=model
         )
     self.assertEqual(len(holder.get_all(timer_type=INTERVAL_TIMER_TRIGGER_REF)), 3)
     self.assertEqual(len(holder.get_all(timer_type=DATE_TIMER_TRIGGER_REF)), 1)
     self.assertEqual(len(holder.get_all(timer_type=CRON_TIMER_TRIGGER_REF)), 1)
Пример #9
0
 def test_remove_trigger(self):
     holder = TimersHolder()
     model = TestTimersHolder.MODELS.get("cron1.yaml", None)
     self.assertIsNotNone(model)
     ref = ResourceReference.to_string_reference(pack=model["pack"],
                                                 name=model["name"])
     holder.add_trigger(ref, model)
     self.assertEqual(len(holder._timers), 1)
     holder.remove_trigger(ref, model)
     self.assertEqual(len(holder._timers), 0)