def test_rule_simple(self):
        fake_config = DotDict()
        fake_config.logger = Mock()
        fake_config.chatty_rules = False
        fake_config.chatty = False

        r1 = transform_rules.Rule(fake_config)
        eq_(r1.predicate(None, None, None, None), True)
        eq_(r1.action(None, None, None, None), True)
        eq_(r1.act(), (True, True))

        class BadPredicate(transform_rules.Rule):
            def _predicate(self, *args, **kwargs):
                return False

        r2 = BadPredicate(fake_config)
        eq_(r2.predicate(None, None, None, None), False)
        eq_(r2.action(None, None, None, None), True)
        eq_(r2.act(), (False, None))

        class BadAction(transform_rules.Rule):
            def _action(self, *args, **kwargs):
                return False

        r3 = BadAction(fake_config)
        eq_(r3.predicate(None, None, None, None), True)
        eq_(r3.action(None, None, None, None), False)
        eq_(r3.act(), (True, False))
Beispiel #2
0
    def test_rule_simple(self):
        fake_config = DotDict()
        fake_config.logger = Mock()

        r1 = transform_rules.Rule(fake_config)
        assert r1.predicate(None, None, None, None) is True
        assert r1.action(None, None, None, None) is True
        assert r1.act() == (True, True)

        class BadPredicate(transform_rules.Rule):
            def _predicate(self, *args, **kwargs):
                return False

        r2 = BadPredicate(fake_config)
        assert r2.predicate(None, None, None, None) is False
        assert r2.action(None, None, None, None) is True
        assert r2.act() == (False, None)

        class BadAction(transform_rules.Rule):
            def _action(self, *args, **kwargs):
                return False

        r3 = BadAction(fake_config)
        assert r3.predicate(None, None, None, None) is True
        assert r3.action(None, None, None, None) is False
        assert r3.act() == (True, False)