Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
8f1ecaf1
Commit
8f1ecaf1
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: added more tests for macro replacement
parent
19119beb
No related branches found
No related tags found
2 merge requests
!123
REL: Release v0.6.0
,
!121
A few more tests for macro replacment
Pipeline
#37494
failed
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_macros.py
+73
-0
73 additions, 0 deletions
unittests/test_macros.py
with
73 additions
and
0 deletions
unittests/test_macros.py
+
73
−
0
View file @
8f1ecaf1
...
@@ -257,6 +257,79 @@ testnode:
...
@@ -257,6 +257,79 @@ testnode:
assert
dat
[
"
testnode
"
][
"
obl
"
][
"
replaced1
"
][
"
d
"
][
1
]
==
"
25
"
assert
dat
[
"
testnode
"
][
"
obl
"
][
"
replaced1
"
][
"
d
"
][
1
]
==
"
25
"
def
test_macros_in_macros
(
register_macros
,
macro_store_reset
):
"""
Test that macros can be used in macro definitions.
"""
cfood
=
_temp_file_load
(
"""
---
metadata:
crawler-version: 0.3.1
macros:
- !defmacro
name: one_macro
params:
a: 25
definition:
macro_sub_$a:
b: $a
another_param: 3
- !defmacro
name: test_macrodef
params: {}
definition:
macro_top: !macro
one_macro:
- a: 17
- {}
- a: 98
not_macro:
a: 26
---
extroot: !macro
test_macrodef:
"""
)
assert
"
test_macro
"
not
in
cfood
[
"
extroot
"
]
assert
cfood
[
"
extroot
"
][
"
macro_top
"
][
"
not_macro
"
][
"
a
"
]
==
26
d
=
cfood
[
"
extroot
"
][
"
macro_top
"
]
assert
d
[
"
macro_sub_17
"
][
"
b
"
]
==
"
17
"
assert
d
[
"
macro_sub_17
"
][
"
another_param
"
]
==
3
assert
d
[
"
macro_sub_25
"
][
"
b
"
]
==
"
25
"
assert
d
[
"
macro_sub_25
"
][
"
another_param
"
]
==
3
assert
d
[
"
macro_sub_98
"
][
"
b
"
]
==
"
98
"
assert
d
[
"
macro_sub_98
"
][
"
another_param
"
]
==
3
def
test_silent_overwrite
(
register_macros
,
macro_store_reset
):
cfood
=
_temp_file_load
(
"""
---
metadata:
crawler-version: 0.3.1
macros:
- !defmacro
name: one_macro
params:
a: 25
definition:
macro_sub:
b: $a
another_param: 3
- !defmacro
name: test_macrodef
params: {}
definition:
macro_top: !macro
one_macro:
- a: 17
- a: 98
---
extroot: !macro
test_macrodef:
"""
)
assert
len
(
cfood
[
"
extroot
"
][
"
macro_top
"
])
==
2
def
test_circular_macro_definition
(
register_macros
,
macro_store_reset
):
def
test_circular_macro_definition
(
register_macros
,
macro_store_reset
):
"""
Test the (ab-)use of macros to create an infinite loop.
"""
"""
Test the (ab-)use of macros to create an infinite loop.
"""
cfood
=
_temp_file_load
(
"""
cfood
=
_temp_file_load
(
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment