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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
b65b8426
Commit
b65b8426
authored
8 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
tests(yaml-models): test for comparisons in yaml model parser
parent
499cbc7d
No related branches found
No related tags found
2 merge requests
!128
MNT: Added a warning when column metadata is not configured, and a better...
,
!115
add datatype, unit and description to properties that are part of Records
Pipeline
#56821
failed
8 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_yaml_model_parser.py
+70
-0
70 additions, 0 deletions
unittests/test_yaml_model_parser.py
with
70 additions
and
0 deletions
unittests/test_yaml_model_parser.py
+
70
−
0
View file @
b65b8426
...
...
@@ -27,6 +27,8 @@ from caosadvancedtools.models.parser import (TwiceDefinedException,
parse_model_from_string
,
parse_model_from_yaml
)
from
linkahead.apiutils
import
compare_entities
def
to_file
(
string
):
f
=
NamedTemporaryFile
(
mode
=
"
w
"
,
delete
=
False
)
...
...
@@ -641,3 +643,71 @@ RT2:
</RecordType>
,
'
bar
'
: <RecordType name=
"
bar
"
/>
}
"""
def
test_comparison_yaml_model
():
"""
Test for this issue:
https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/issues/130
"""
model_string
=
"""
foo:
datatype: INTEGER
description: bla bla
unit: m
RT1:
obligatory_properties:
foo:
RT2:
test_reference:
RT2:
test_reference:
datatype: RT2
"""
model
=
parse_model_from_string
(
model_string
)
# Without the fix, foo will have no datatype, description and no unit **as part of RT1**, so the
# comparison with a version taken from a LinkAhead instance will have these attributes.
# Furthermore, RT2 will be set as the datatype **in object version** in the yaml definition, while
# it is an ID in case of the version from the LinkAhead instance.
p_foo
=
db
.
Property
(
name
=
"
foo
"
,
datatype
=
"
INTEGER
"
,
description
=
"
bla bla
"
,
unit
=
"
m
"
)
rt2
=
db
.
RecordType
(
name
=
"
RT2
"
)
rt1
=
db
.
RecordType
(
name
=
"
RT1
"
)
rt1
.
add_property
(
p_foo
)
rt1
.
add_property
(
rt2
)
server_response
=
"""
<Entities>
<noscript>
</noscript>
<Property id=
"
2272
"
name=
"
foo
"
description=
"
bla bla
"
datatype=
"
INTEGER
"
unit=
"
m
"
>
<Version id=
"
7819eedaeba2aa7305e10c96e8cf7b9ac84aea4a
"
head=
"
true
"
/>
</Property>
<RecordType id=
"
2273
"
name=
"
RT1
"
>
<Version id=
"
0c1b9df6677ee40d1e1429b2123e078ee6c863e0
"
head=
"
true
"
/>
<Property id=
"
2272
"
name=
"
foo
"
description=
"
bla bla
"
datatype=
"
INTEGER
"
unit=
"
m
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2274
"
name=
"
RT2
"
datatype=
"
RT2
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
<RecordType id=
"
2274
"
name=
"
RT2
"
>
<Version id=
"
185940642680a7eba7f71914dd8dd7758dd13faa
"
head=
"
true
"
/>
</RecordType>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
>
<Version id=
"
03cf86061c78a079b376394dfecdf32566b72fb7
"
head=
"
true
"
/>
</Property>
</Entities>
"""
entities
=
db
.
Container
.
from_xml
(
server_response
)
c1
=
compare_entities
(
model
[
"
foo
"
],
entities
[
0
])
c2
=
compare_entities
(
model
[
"
RT1
"
],
entities
[
1
])
c3
=
compare_entities
(
model
[
"
RT2
"
],
entities
[
2
])
c4
=
compare_entities
(
model
[
"
test_reference
"
],
entities
[
3
])
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