Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
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-advanced-user-tools
Commits
a90a2c74
Verified
Commit
a90a2c74
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Enhanced YAML features.
parent
dbb2c0f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!100
WIP: Filling XLSX: Seems to be working.
,
!94
ENH: add framework for converting json schema into table templates
,
!93
Filling XLSX: Everything except multiple choice.
Pipeline
#44998
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_yaml_model_parser.py
+47
-0
47 additions, 0 deletions
unittests/test_yaml_model_parser.py
with
47 additions
and
0 deletions
unittests/test_yaml_model_parser.py
+
47
−
0
View file @
a90a2c74
...
@@ -597,3 +597,50 @@ prop2:
...
@@ -597,3 +597,50 @@ prop2:
model
=
parse_model_from_string
(
model_string
)
model
=
parse_model_from_string
(
model_string
)
prop2
=
model
[
"
prop2
"
]
prop2
=
model
[
"
prop2
"
]
assert
prop2
.
role
==
"
Property
"
assert
prop2
.
role
==
"
Property
"
def
test_fancy_yaml
():
"""
Testing aliases and other fancy YAML features.
"""
# Simple aliasing
model_string
=
"""
foo:
datatype: INTEGER
RT1:
obligatory_properties: &RT1_oblig
foo:
RT2:
obligatory_properties: *RT1_oblig
"""
model
=
parse_model_from_string
(
model_string
)
assert
str
(
model
)
==
"""
{
'
foo
'
: <Property name=
"
foo
"
datatype=
"
INTEGER
"
/>
,
'
RT1
'
: <RecordType name=
"
RT1
"
>
<Property name=
"
foo
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
,
'
RT2
'
: <RecordType name=
"
RT2
"
>
<Property name=
"
foo
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
}
"""
# Aliasing with override
model_string
=
"""
foo:
datatype: INTEGER
RT1:
obligatory_properties: &RT1_oblig
foo:
RT2:
obligatory_properties:
<<: *RT1_oblig
bar:
"""
model
=
parse_model_from_string
(
model_string
)
assert
str
(
model
)
==
"""
{
'
foo
'
: <Property name=
"
foo
"
datatype=
"
INTEGER
"
/>
,
'
RT1
'
: <RecordType name=
"
RT1
"
>
<Property name=
"
foo
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
,
'
RT2
'
: <RecordType name=
"
RT2
"
>
<Property name=
"
foo
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property name=
"
bar
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
,
'
bar
'
: <RecordType name=
"
bar
"
/>
}
"""
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