Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | # coding: utf8 |
||
12 | class PreviewTestCase(unittest.TestCase): |
||
13 | def test_simple_preview(self): |
||
14 | a = Action("a") |
||
15 | self.assertEqual(a.get_possible_execution_order(), [a]) |
||
16 | |||
17 | def test_preview_twice(self): |
||
18 | # There was a bug where a second call to get_possible_execution_order would return [] :-/ |
||
19 | a = Action("a") |
||
20 | self.assertEqual(a.get_possible_execution_order(), [a]) |
||
21 | self.assertEqual(a.get_possible_execution_order(), [a]) |
||
22 | |||
23 | def test_deep_dependency(self): |
||
24 | a = Action("a") |
||
25 | b = Action("b") |
||
26 | c = Action("c") |
||
27 | d = Action("d") |
||
28 | a.add_dependency(b) |
||
29 | b.add_dependency(c) |
||
30 | c.add_dependency(d) |
||
31 | |||
32 | self.assertEqual(a.get_possible_execution_order(), [d, c, b, a]) |
||
33 | |||
34 | def test_diamond_dependency(self): |
||
35 | # a |
||
36 | # / \ |
||
37 | # b c |
||
38 | # \ / |
||
39 | # d |
||
40 | |||
41 | a = Action("a") |
||
42 | b = Action("b") |
||
43 | c = Action("c") |
||
44 | d = Action("d") |
||
45 | a.add_dependency(b) |
||
46 | a.add_dependency(c) |
||
47 | b.add_dependency(d) |
||
48 | c.add_dependency(d) |
||
49 | |||
50 | self.assertEqual(a.get_possible_execution_order(), [d, b, c, a]) |
||
51 |