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)
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)
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)
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)
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)
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)
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)
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)
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)