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
f8b92cdd
Commit
f8b92cdd
authored
7 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
fix(yaml-models): corrected output labels for the yaml model parser
parent
b71b7aa4
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...
,
!119
Correct labels in yaml model parser
Pipeline
#56814
failed
7 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
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
+44
-0
44 additions, 0 deletions
unittests/test_yaml_model_parser.py
with
48 additions
and
2 deletions
src/caosadvancedtools/models/data_model.py
+
4
−
2
View file @
f8b92cdd
...
...
@@ -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
+
44
−
0
View file @
f8b92cdd
...
...
@@ -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
,
...
...
@@ -641,3 +645,43 @@ RT2:
</RecordType>
,
'
bar
'
: <RecordType name=
"
bar
"
/>
}
"""
def
test_sync_output
(
capfd
):
model
=
parse_model_from_string
(
"""
RT:
obligatory_properties:
identifier:
datatype: TEXT
"""
)
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