Ejemplo n.º 1
0
    def test_ComposedRule(self, ms):
        rule1 = Always()
        rule2 = Never()

        composed = rule1 & rule2
        self.assertIsInstance(composed, ComposedRule)
        self.assertIs(composed.first, rule1)
        self.assertIs(composed.second, rule2)
        self.assertFalse(any(map(composed.should_trigger, ms)))
Ejemplo n.º 2
0
    def test_ComposedRule(self):
        minute_groups = minutes_for_days(self.cal)
        rule1 = Always()
        rule2 = Never()

        for minute in minute_groups:
            composed = rule1 & rule2
            should_trigger = composed.should_trigger
            self.assertIsInstance(composed, ComposedRule)
            self.assertIs(composed.first, rule1)
            self.assertIs(composed.second, rule2)
            self.assertFalse(any(map(should_trigger, minute)))
Ejemplo n.º 3
0
    def test_ComposedRule(self):
        minute_groups = minutes_for_days(self.cal)
        rule1 = Always()
        rule2 = Never()

        for minute in minute_groups:
            composed = rule1 & rule2
            should_trigger = composed.should_trigger
            assert isinstance(composed, ComposedRule)
            assert composed.first is rule1
            assert composed.second is rule2
            assert not any(map(should_trigger, minute))
Ejemplo n.º 4
0
 def test_Always(self, ms):
     should_trigger = Always().should_trigger
     self.assertTrue(all(map(should_trigger, ms)))
Ejemplo n.º 5
0
 def test_not_implemented(self):
     with self.assertRaises(NotImplementedError):
         super(Always, Always()).should_trigger('a')
Ejemplo n.º 6
0
 def setUp(self):
     self.em = EventManager()
     self.event1 = Event(Always(), lambda context, data: None)
     self.event2 = Event(Always(), lambda context, data: None)
Ejemplo n.º 7
0
 def test_Always(self, ms):
     should_trigger = partial(Always().should_trigger, env=self.env)
     self.assertTrue(all(map(partial(should_trigger, env=self.env), ms)))
Ejemplo n.º 8
0
 def test_Always(self):
     should_trigger = Always().should_trigger
     for session_minutes in minutes_for_days(self.cal):
         self.assertTrue(all(map(should_trigger, session_minutes)))
Ejemplo n.º 9
0
 def setUp(self):
     self.em = EventManager()
     self.event1 = Event(Always())
     self.event2 = Event(Always())
Ejemplo n.º 10
0
 def test_Always(self):
     should_trigger = Always().should_trigger
     self.assertTrue(all(map(should_trigger, self.minutes)))
Ejemplo n.º 11
0
 def test_not_implemented(self):
     with pytest.raises(NotImplementedError):
         super(Always, Always()).should_trigger("a")
Ejemplo n.º 12
0
def set_event_manager(request):
    request.cls.em = EventManager()
    request.cls.event1 = Event(Always())
    request.cls.event2 = Event(Always())