def test_exclusive_ab(self): rs = RuleSet() rs.addDep("a", "b") rs.addConflict("a", "b") self.assertFalse(rs.isCoherent(), "rs.isCoherent failed")
def test_deep_deps(self): rs = RuleSet() rs.addDep("a", "b") rs.addDep("b", "c") rs.addDep("c", "d") rs.addDep("d", "e") rs.addDep("a", "f") rs.addConflict("e", "f") self.assertFalse(rs.isCoherent(), "rs.isCoherent failed")
def test_exclusive_ab_bc_ca_de(self): rs = RuleSet() rs.addDep("a", "b") rs.addDep("b", "c") rs.addDep("c", "a") rs.addDep("d", "e") rs.addConflict("c", "e") self.assertTrue(rs.isCoherent(), "rs.isCoherent failed") opts = Options(rs) opts.toggle("a") self.assertSetEqual( opts.selection(), set(["a", "c", "b"]), "toggle expected (a, c, b) got %s" % opts.selection(), ) rs.addDep("f", "f") opts.toggle("f") self.assertSetEqual( opts.selection(), set(["a", "c", "b", "f"]), "toggle expected (a, c, b, f) got %s" % opts.selection(), ) opts.toggle("e") self.assertSetEqual( opts.selection(), set(["e", "f"]), "toggle expected (e, f) got %s" % opts.selection(), ) opts.toggle("b") self.assertSetEqual( opts.selection(), set(["a", "c", "b", "f"]), "toggle expected (a, c, b, f) got %s" % opts.selection(), ) rs.addDep("b", "g") opts.toggle("g") opts.toggle("b") self.assertSetEqual( opts.selection(), set(["g", "f"]), "toggle expected (g, f) got %s" % opts.selection(), )
def test_ab_ac(self): rs = RuleSet() rs.addDep("a", "b") rs.addDep("a", "c") rs.addConflict("b", "d") rs.addConflict("b", "e") self.assertTrue(rs.isCoherent(), "rs.isCoherent failed") opts = Options(rs) opts.toggle("d") opts.toggle("e") opts.toggle("a") self.assertSetEqual( opts.selection(), set(["a", "c", "b"]), "toggle expected (a, c, b) got %s" % opts.selection(), )