def test_init(): evaluator = create_evaluator(False) definition = "foo-bar" r = rule.Simple(definition, evaluator) assert r.definition == definition assert r.evaluator is evaluator
def test_resolve_not_matching(): evaluator = create_evaluator(False) definition = "foo-bar" not_definition = "bar-foo" role = mock.Mock() instance = rule.Simple(definition, evaluator) with pytest.raises(ValueError): instance.resolve(role, not_definition)
def test_resolve_false(): evaluator = create_evaluator(False) definition = "foo-bar" role = mock.Mock() instance = rule.Simple(definition, evaluator) result = instance.resolve(role, definition) assert not result.is_allowed assert result.level == 0
def setup_rules(acl): acl.add_rule("user", rules.Simple("index.index", evaluators.allow))