1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
diff --git a/tests/unit/pydsl_test.py b/tests/unit/pydsl_test.py
index 59442bd..2c5d129 100644
--- a/tests/unit/pydsl_test.py
+++ b/tests/unit/pydsl_test.py
@@ -297,99 +297,6 @@ class PyDSLRendererTestCase(TestCase):
finally:
shutil.rmtree(dirpath, ignore_errors=True)
- def test_rendering_includes(self):
- dirpath = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
- if not os.path.isdir(dirpath):
- self.skipTest(
- 'The temporary directory {0!r} was not created'.format(
- dirpath
- )
- )
- output = os.path.join(dirpath, 'output')
- try:
- write_to(os.path.join(dirpath, 'aaa.sls'), textwrap.dedent('''\
- #!pydsl|stateconf -ps
-
- include('xxx')
- yyy = include('yyy')
-
- # ensure states in xxx are run first, then those in yyy and then those in aaa last.
- extend(state('yyy::start').stateconf.require(stateconf='xxx::goal'))
- extend(state('.start').stateconf.require(stateconf='yyy::goal'))
-
- extend(state('yyy::Y2').cmd.run('echo Y2 extended >> {0}'))
-
- __pydsl__.set(ordered=True)
-
- yyy.hello('red', 1)
- yyy.hello('green', 2)
- yyy.hello('blue', 3)
- '''.format(output)))
-
- write_to(os.path.join(dirpath, 'xxx.sls'), textwrap.dedent('''\
- #!stateconf -os yaml . jinja
-
- include:
- - yyy
-
- extend:
- yyy::start:
- stateconf.set:
- - require:
- - stateconf: .goal
-
- yyy::Y1:
- cmd.run:
- - name: 'echo Y1 extended >> {0}'
-
- .X1:
- cmd.run:
- - name: echo X1 >> {1}
- - cwd: /
- .X2:
- cmd.run:
- - name: echo X2 >> {2}
- - cwd: /
- .X3:
- cmd.run:
- - name: echo X3 >> {3}
- - cwd: /
-
- '''.format(output, output, output, output)))
-
- write_to(os.path.join(dirpath, 'yyy.sls'), textwrap.dedent('''\
- #!pydsl|stateconf -ps
-
- include('xxx')
- __pydsl__.set(ordered=True)
-
- state('.Y1').cmd.run('echo Y1 >> {0}', cwd='/')
- state('.Y2').cmd.run('echo Y2 >> {1}', cwd='/')
- state('.Y3').cmd.run('echo Y3 >> {2}', cwd='/')
-
- def hello(color, number):
- state(color).cmd.run('echo hello '+color+' '+str(number)+' >> {3}', cwd='/')
- '''.format(output, output, output, output)))
-
- state_highstate({'base': ['aaa']}, dirpath)
- expected = textwrap.dedent('''\
- X1
- X2
- X3
- Y1 extended
- Y2 extended
- Y3
- hello red 1
- hello green 2
- hello blue 3
- ''')
-
- with open(output, 'r') as f:
- self.assertEqual(sorted(f.read()), sorted(expected))
-
- finally:
- shutil.rmtree(dirpath, ignore_errors=True)
-
def test_compile_time_state_execution(self):
if not sys.stdin.isatty():
self.skipTest('Not attached to a TTY')
|