Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
software
gridtk
Commits
a9b5d476
Commit
a9b5d476
authored
Dec 05, 2017
by
André Anjos
💬
Browse files
Merge branch 'unique' into 'master'
Add tests for jgen --unique-aggregate See merge request
!15
parents
43de8af2
dc1a5a1c
Pipeline
#14602
passed with stages
in 21 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gridtk/tests/test_generator.py
View file @
a9b5d476
...
...
@@ -195,3 +195,83 @@ def test_cmdline_aggregation():
finally
:
shutil
.
rmtree
(
tmpdir
)
def
test_cmdline_unique_aggregation
():
data
=
\
'name: [john, lisa]
\n
'
\
'version: [v1, v2]'
template
=
'{{ name }}-{{ version }}'
aggtmpl
=
'''{% for k in cfgset %}
# comment lines and empty lines should repeat
# k.name
{{ k.name }}
# k.version
{{ k.version }}
{% endfor %}
'''
gen_expected
=
[
'john-v1'
,
'john-v2'
,
'lisa-v1'
,
'lisa-v2'
,
]
agg_expected
=
'
\n
'
.
join
([
''
,
'# comment lines and empty lines should repeat'
,
'# k.name'
,
'john'
,
'# k.version'
,
'v1'
,
''
,
'# comment lines and empty lines should repeat'
,
'# k.name'
,
'# k.version'
,
'v2'
,
''
,
'# comment lines and empty lines should repeat'
,
'# k.name'
,
'lisa'
,
'# k.version'
,
''
,
'# comment lines and empty lines should repeat'
,
'# k.name'
,
'# k.version'
,
''
,
''
,
])
tmpdir
=
tempfile
.
mkdtemp
()
try
:
variables
=
os
.
path
.
join
(
tmpdir
,
'variables.yaml'
)
with
open
(
variables
,
'wt'
)
as
f
:
f
.
write
(
data
)
gentmpl
=
os
.
path
.
join
(
tmpdir
,
'gentmpl.txt'
)
with
open
(
gentmpl
,
'wt'
)
as
f
:
f
.
write
(
template
)
genout
=
os
.
path
.
join
(
tmpdir
,
'out'
,
'{{ name }}-{{ version }}.txt'
)
aggtmpl_file
=
os
.
path
.
join
(
tmpdir
,
'agg.txt'
)
with
open
(
aggtmpl_file
,
'wt'
)
as
f
:
f
.
write
(
aggtmpl
)
aggout
=
os
.
path
.
join
(
tmpdir
,
'out'
,
'agg.txt'
)
nose
.
tools
.
eq_
(
jgen
.
main
([
'-vv'
,
'-u'
,
variables
,
gentmpl
,
genout
,
aggtmpl_file
,
aggout
]),
0
)
# check all files are there and correspond to the expected output
outdir
=
os
.
path
.
dirname
(
genout
)
for
k
in
gen_expected
:
ofile
=
os
.
path
.
join
(
outdir
,
k
+
'.txt'
)
assert
os
.
path
.
exists
(
ofile
)
with
open
(
ofile
,
'rt'
)
as
f
:
contents
=
f
.
read
()
nose
.
tools
.
eq_
(
contents
,
k
)
assert
os
.
path
.
exists
(
aggout
)
with
open
(
aggout
,
'rt'
)
as
f
:
contents
=
f
.
read
()
nose
.
tools
.
eq_
(
contents
,
agg_expected
)
finally
:
shutil
.
rmtree
(
tmpdir
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment