Completed
Push — master ( a4f2fd...4fbdfd )
by Vincent
01:14
created

ChangeEnvironAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A do_execute() 0 3 1
1
# coding: utf8
2
3
# Copyright 2013-2017 Vincent Jacques <[email protected]>
4
5
from __future__ import division, absolute_import, print_function
6
7
import os
8
import unittest
9
10
from ActionTree import *
11
from ActionTree.stock import *
12
13
14
class ChdirAction(Action):
15
    def do_execute(self):
16
        print(os.getcwd())
17
        os.chdir("/")
18
19
20
class ChangeEnvironAction(Action):
21
    def do_execute(self):
22
        print(os.environ.get("FOO"))
23
        os.environ["FOO"] = "bar"
24
25
26
class ProcessWideStateTestCase(unittest.TestCase):
27
    def test_working_directory(self):
28
        a = ChdirAction("a")
29
        b = ChdirAction("b")
30
        a.add_dependency(b)
31
32
        report = execute(a)
33
        self.assertEqual(report.get_action_status(a).output, report.get_action_status(b).output)
34
35
    def test_environment(self):
36
        a = ChangeEnvironAction("a")
37
        b = ChangeEnvironAction("b")
38
        a.add_dependency(b)
39
40
        report = execute(a)
41
        self.assertEqual(report.get_action_status(a).output, report.get_action_status(b).output)
42