Skip to content
Snippets Groups Projects
Commit d86d2603 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-def-replacements' into 'dev'

TST def replacements

See merge request !54
parents 9b5757f5 7d1569b5
No related branches found
No related tags found
2 merge requests!71REL: RElease v0.2.0,!54TST def replacements
Pipeline #30485 passed
...@@ -327,7 +327,6 @@ extroot: !macro ...@@ -327,7 +327,6 @@ extroot: !macro
assert cfood["extroot"]["once"]["something"]["a"] == "4" assert cfood["extroot"]["once"]["something"]["a"] == "4"
assert cfood["extroot"]["twice"]["something"]["a"] == "5" assert cfood["extroot"]["twice"]["something"]["a"] == "5"
assert cfood["extroot"]["default_name"]["something"]["a"] == "4" assert cfood["extroot"]["default_name"]["something"]["a"] == "4"
# Code sample to generate the expanded macro: # Code sample to generate the expanded macro:
# with open("expanded_test_macro.yaml", "w") as f: # with open("expanded_test_macro.yaml", "w") as f:
# f.write(yaml.dump(cfood)) # f.write(yaml.dump(cfood))
...@@ -409,3 +408,51 @@ SimulationData: ...@@ -409,3 +408,51 @@ SimulationData:
# Code sample to generate the expanded macro: # Code sample to generate the expanded macro:
# with open("expanded_test_macro.yaml", "w") as f: # with open("expanded_test_macro.yaml", "w") as f:
# f.write(yaml.dump(cfood)) # f.write(yaml.dump(cfood))
@pytest.mark.xfail(
reason="Wait until this feature is implemented"
"https://gitlab.com/caosdb/caosdb-crawler/-/issues/21."
)
def test_def_replacements():
"""Test that parameters in macro definitions can be used
for defining subsequent parameters.
"""
cfood = _temp_file_load("""
---
metadata:
macros:
- !defmacro
name: test_def_replacements
params:
macro_name: default_name
z: $macro_name
a: $macro_name
v: $z
definition:
$macro_name:
macro_name: $macro_name
z: $z
a: $a
v: $v
---
extroot: !macro
test_def_replacements:
- macro_name: once
- macro_name: twice
z: 5
- {}
""")
assert cfood["extroot"]["once"]["z"] == "once"
assert cfood["extroot"]["once"]["a"] == "once"
assert cfood["extroot"]["once"]["v"] == "once"
assert cfood["extroot"]["once"]["macro_name"] == "once"
assert cfood["extroot"]["twice"]["z"] == "5"
assert cfood["extroot"]["twice"]["a"] == "5"
assert cfood["extroot"]["twice"]["v"] == "5"
assert cfood["extroot"]["twice"]["macro_name"] == "twice"
assert cfood["extroot"]["default_name"]["z"] == "default_name"
assert cfood["extroot"]["default_name"]["a"] == "default_name"
assert cfood["extroot"]["default_name"]["v"] == "default_name"
assert cfood["extroot"]["default_name"]["macro_name"] == "default_name"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment