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
5f8a472d
Commit
5f8a472d
authored
6 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
fix(yaml-models): corrected output labels for the yaml model parser
parent
a76cf9a5
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...
,
!118
Test to confirm (or reject) #71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/models/data_model.py
+4
-2
4 additions, 2 deletions
src/caosadvancedtools/models/data_model.py
unittests/test_yaml_model_parser.py
+56
-12
56 additions, 12 deletions
unittests/test_yaml_model_parser.py
with
60 additions
and
14 deletions
src/caosadvancedtools/models/data_model.py
+
4
−
2
View file @
5f8a472d
...
...
@@ -145,8 +145,10 @@ class DataModel(dict):
else
:
query
=
db
.
Query
(
f
"
FIND ENTITY with id=
{
ent
.
id
}
"
)
ref
=
query
.
execute
(
unique
=
True
)
diff
=
(
describe_diff
(
*
compare_entities
(
ent
,
ref
),
name
=
ent
.
name
))
diff
=
(
describe_diff
(
*
compare_entities
(
ent
,
ref
),
name
=
ent
.
name
,
label_old
=
"
version from the yaml file
"
,
label_new
=
"
version from LinkAhead
"
))
if
diff
!=
""
:
if
verbose
:
...
...
This diff is collapsed.
Click to expand it.
unittests/test_yaml_model_parser.py
+
56
−
12
View file @
5f8a472d
...
...
@@ -21,7 +21,11 @@ from datetime import date
from
tempfile
import
NamedTemporaryFile
from
pytest
import
raises
,
mark
from
unittest.mock
import
Mock
import
linkahead
as
db
import
caosadvancedtools
from
caosadvancedtools.models.parser
import
(
TwiceDefinedException
,
YamlDefinitionError
,
parse_model_from_string
,
...
...
@@ -644,18 +648,58 @@ RT2:
def
test_setting_values
():
model
=
parse_model_from_string
(
"""
parameter:
datatype: INTEGER
Simulation:
role: Record
model
=
parse_model_from_string
(
"""
parameter:
datatype: INTEGER
Simulation:
role: Record
obligatory_properties:
parameter: 26
"""
)
assert
len
(
model
)
==
2
assert
str
(
model
[
"
parameter
"
])[:
-
1
]
==
'
<Property name=
"
parameter
"
datatype=
"
INTEGER
"
/>
'
assert
model
[
"
Simulation
"
].
role
==
"
Record
"
assert
model
[
"
Simulation
"
].
name
==
"
Simulation
"
assert
model
[
"
Simulation
"
].
get_property
(
"
parameter
"
).
value
==
26
def
test_sync_output
(
capfd
):
model
=
parse_model_from_string
(
"""
RT:
obligatory_properties:
parameter: 26
identifier:
datatype: TEXT
"""
)
assert
len
(
model
)
==
2
assert
str
(
model
[
"
parameter
"
])[:
-
1
]
==
'
<Property name=
"
parameter
"
datatype=
"
INTEGER
"
/>
'
assert
model
[
"
Simulation
"
].
role
==
"
Record
"
assert
model
[
"
Simulation
"
].
name
==
"
Simulation
"
assert
model
[
"
Simulation
"
].
get_property
(
"
parameter
"
).
value
==
26
existing_entities
=
[
db
.
RecordType
(
name
=
"
RT
"
,
id
=
25
).
add_property
(
name
=
"
identifier
"
,
datatype
=
"
INTEGER
"
,
importance
=
"
OBLIGATORY
"
,
id
=
24
),
db
.
Property
(
name
=
"
identifier
"
,
datatype
=
"
INTEGER
"
,
id
=
24
)]
def
get_existing_entities
(
ent_cont
):
return
existing_entities
class
MockQuery
:
def
__init__
(
self
,
q
):
self
.
q
=
q
def
execute
(
self
,
unique
=
True
):
id
=
int
(
self
.
q
.
split
(
"
=
"
)[
1
])
for
existing_ent
in
existing_entities
:
if
existing_ent
.
id
==
id
:
return
existing_ent
return
None
model
.
get_existing_entities
=
get_existing_entities
caosadvancedtools
.
models
.
parser
.
db
.
Query
=
MockQuery
caosadvancedtools
.
models
.
parser
.
db
.
Container
.
update
=
Mock
()
model
.
sync_data_model
(
True
,
True
)
assert
caosadvancedtools
.
models
.
parser
.
db
.
Container
.
update
.
called
output
,
err
=
capfd
.
readouterr
()
print
(
output
)
assert
"
version from the yaml file: TEXT
"
in
output
assert
"
version from LinkAhead: INTEGER
"
in
output
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