def test_constraint_any_basic(): """Test the all operation""" sc1 = SimpleConstraint(value='value_1') sc2 = SimpleConstraint(value='value_2') c = Constraint([sc1, sc2], reduce=Constraint.any) match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_2') assert match match, reprocess = c.check_and_set('value_3') assert not match
def test_constraint_any_remember(): """Ensure that any doesn't forget other or propositions""" sc1 = SimpleConstraint(value='value_1') sc2 = SimpleConstraint(value='value_2') c = Constraint([sc1, sc2], reduce=Constraint.any) match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_2') assert match match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_3') assert not match
def test_constraint_reprocess_nomatch(): """Test options for reprocessing""" sc = SimpleConstraint(value='my_value') c = Constraint([sc], reprocess_on_fail=True) match, reprocess = c.check_and_set('bad_value') assert not match assert len(reprocess)
def test_constraint_default(): """Test constraint operations""" sc1 = SimpleConstraint() sc2 = SimpleConstraint() c = Constraint([sc1, sc2]) match, reprocess = c.check_and_set('my_value') assert match for constraint in c.constraints: assert constraint.value == 'my_value'