PreviewTestCase.test_simple_preview()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
# coding: utf8
2
3
# Copyright 2013-2018 Vincent Jacques <[email protected]>
4
5
from __future__ import division, absolute_import, print_function
6
7
import unittest
8
9
from ActionTree import *
10
11
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