Completed
Push — master ( 2ae69e...39840a )
by Vincent
01:14
created

__create_mocked_action()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 2
1
# coding: utf8
2
3
# Copyright 2013-2015 Vincent Jacques <[email protected]>
4
5
from __future__ import division, absolute_import, print_function
6
7
from ActionTree import *
8
from . import *
9
10
11
class MultipleExecutionsTestCase(ActionTreeTestCase):
12
    REPEAT = 5
13
14
    def test_simple_success(self):
15
        a = self._action("a")
16
17
        for i in range(self.REPEAT):
18
            report = execute(a)
19
            self.assertEqual(report.get_action_status(a).status, ExecutionReport.ActionStatus.Successful)
20
21
        self.assertEventsEqual("a " * self.REPEAT)
22
23 View Code Duplication
    def test_failure_in_middle(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
24
        a = self._action("a")
25
        b = self._action("b", exception=Exception())
26
        c = self._action("c")
27
        a.add_dependency(b)
28
        b.add_dependency(c)
29
30
        for i in range(self.REPEAT):
31
            with self.assertRaises(CompoundException) as catcher:
32
                execute(a)
33
            report = catcher.exception.execution_report
34
            self.assertEqual(report.get_action_status(a).status, ExecutionReport.ActionStatus.Canceled)
35
            self.assertEqual(report.get_action_status(b).status, ExecutionReport.ActionStatus.Failed)
36
            self.assertEqual(report.get_action_status(c).status, ExecutionReport.ActionStatus.Successful)
37
38
        self.assertEventsEqual("c b " * self.REPEAT)
39