Skip to content

Commit

Permalink
Better (separated, simpler) tests for all_arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
fisadev committed Nov 23, 2013
1 parent 0a46d0b commit acb8338
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions tests/search/test_arc_concistency.py
Expand Up @@ -11,21 +11,23 @@
class TestAllArcs(unittest.TestCase):

def setUp(self):
constraint = lambda variables, values: False
self.constraints = [(('A', 'B'), constraint),
(('A', 'C'), constraint),
(('C', 'A'), constraint),
(('B', 'C'), constraint)]

def test_all_arcs(self):
# does not check that the constraint function is well created
arcs_result = all_arcs(self.constraints)
arcs_expected = [('A', 'B'),
('B', 'A'),
('A', 'C'),
('C', 'A'),
('B', 'C'),
('C', 'B')]
self.constraint = lambda variables, values: False

def test_adds_pairs_in_both_directions(self):
constraints = [(('A', 'B'), self.constraint)]

arcs_result = all_arcs(constraints)
arcs_expected = set([('A', 'B'),
('B', 'A')])

self.assertEqual(arcs_result, arcs_expected)

def test_constraints_with_more_than_2_neighbors_arent_added(self):
constraints = [(('A', 'B', 'C'), self.constraint)]

arcs_result = all_arcs(constraints)
arcs_expected = set()

self.assertEqual(arcs_result, arcs_expected)


Expand Down

0 comments on commit acb8338

Please sign in to comment.