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
0e6af72e
Commit
0e6af72e
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX: set retrieve false; has_parent now by default retrieves parents
parent
68d165ba
No related branches found
No related tags found
2 merge requests
!69
Release v0.7.0
,
!67
F fix has parent
Pipeline
#33904
failed
2 years 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
unittests/test_json_schema_model_parser.py
+4
-4
4 additions, 4 deletions
unittests/test_json_schema_model_parser.py
unittests/test_yaml_model_parser.py
+5
-13
5 additions, 13 deletions
unittests/test_yaml_model_parser.py
with
9 additions
and
17 deletions
unittests/test_json_schema_model_parser.py
+
4
−
4
View file @
0e6af72e
...
@@ -164,7 +164,7 @@ def test_enum():
...
@@ -164,7 +164,7 @@ def test_enum():
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
model
[
name
].
name
==
name
assert
model
[
name
].
name
==
name
assert
len
(
model
[
name
].
parents
)
==
1
assert
len
(
model
[
name
].
parents
)
==
1
assert
model
[
name
].
has_parent
(
model
[
"
license
"
])
assert
model
[
name
].
has_parent
(
model
[
"
license
"
]
,
retrieve
=
False
)
# Also allow enums with non-string types
# Also allow enums with non-string types
number_enums
=
[
"
1.1
"
,
"
2.2
"
,
"
3.3
"
]
number_enums
=
[
"
1.1
"
,
"
2.2
"
,
"
3.3
"
]
...
@@ -181,7 +181,7 @@ def test_enum():
...
@@ -181,7 +181,7 @@ def test_enum():
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
model
[
name
].
name
==
name
assert
model
[
name
].
name
==
name
assert
len
(
model
[
name
].
parents
)
==
1
assert
len
(
model
[
name
].
parents
)
==
1
assert
model
[
name
].
has_parent
(
model
[
"
number_enum
"
])
assert
model
[
name
].
has_parent
(
model
[
"
number_enum
"
]
,
retrieve
=
False
)
@pytest.mark.xfail
(
reason
=
"
Don
'
t allow integer enums until https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/issues/224 has been fixed
"
)
@pytest.mark.xfail
(
reason
=
"
Don
'
t allow integer enums until https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/issues/224 has been fixed
"
)
...
@@ -207,7 +207,7 @@ def test_int_enum():
...
@@ -207,7 +207,7 @@ def test_int_enum():
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
model
[
name
].
name
==
name
assert
model
[
name
].
name
==
name
assert
len
(
model
[
name
].
parents
)
==
1
assert
len
(
model
[
name
].
parents
)
==
1
assert
model
[
name
].
has_parent
(
model
[
"
int_enum
"
])
assert
model
[
name
].
has_parent
(
model
[
"
int_enum
"
]
,
retrieve
=
False
)
def
test_references
():
def
test_references
():
...
@@ -339,7 +339,7 @@ def test_list():
...
@@ -339,7 +339,7 @@ def test_list():
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
isinstance
(
model
[
name
],
db
.
Record
)
assert
model
[
name
].
name
==
name
assert
model
[
name
].
name
==
name
assert
len
(
model
[
name
].
parents
)
==
1
assert
len
(
model
[
name
].
parents
)
==
1
assert
model
[
name
].
has_parent
(
model
[
"
license
"
])
assert
model
[
name
].
has_parent
(
model
[
"
license
"
]
,
retrieve
=
False
)
def
test_name_property
():
def
test_name_property
():
...
...
This diff is collapsed.
Click to expand it.
unittests/test_yaml_model_parser.py
+
5
−
13
View file @
0e6af72e
...
@@ -32,14 +32,6 @@ def has_property(el, name):
...
@@ -32,14 +32,6 @@ def has_property(el, name):
return
False
return
False
def
has_parent
(
el
,
name
):
for
p
in
el
.
get_parents
():
if
p
.
name
==
name
:
return
True
return
False
class
TwiceTest
(
unittest
.
TestCase
):
class
TwiceTest
(
unittest
.
TestCase
):
def
test_defined_once
(
self
):
def
test_defined_once
(
self
):
string
=
"""
string
=
"""
...
@@ -148,16 +140,16 @@ RT4:
...
@@ -148,16 +140,16 @@ RT4:
RT5:
RT5:
"""
"""
model
=
parse_model_from_yaml
(
to_file
(
string
))
model
=
parse_model_from_yaml
(
to_file
(
string
))
assert
has_parent
(
model
[
"
RT1
"
],
"
RT2
"
)
assert
model
[
"
RT1
"
].
has_parent
(
"
RT2
"
,
retrieve
=
False
)
assert
(
model
[
"
RT1
"
].
get_parent
(
assert
(
model
[
"
RT1
"
].
get_parent
(
"
RT2
"
).
_flags
[
"
inheritance
"
]
==
db
.
SUGGESTED
)
"
RT2
"
).
_flags
[
"
inheritance
"
]
==
db
.
SUGGESTED
)
assert
has_parent
(
model
[
"
RT1
"
],
"
RT3
"
)
assert
model
[
"
RT1
"
].
has_parent
(
"
RT3
"
,
retrieve
=
False
)
assert
(
model
[
"
RT1
"
].
get_parent
(
assert
(
model
[
"
RT1
"
].
get_parent
(
"
RT3
"
).
_flags
[
"
inheritance
"
]
==
db
.
RECOMMENDED
)
"
RT3
"
).
_flags
[
"
inheritance
"
]
==
db
.
RECOMMENDED
)
assert
has_parent
(
model
[
"
RT1
"
],
"
RT4
"
)
assert
model
[
"
RT1
"
].
has_parent
(
"
RT4
"
,
retrieve
=
False
)
assert
(
model
[
"
RT1
"
].
get_parent
(
assert
(
model
[
"
RT1
"
].
get_parent
(
"
RT4
"
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
)
"
RT4
"
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
)
assert
has_parent
(
model
[
"
RT1
"
],
"
RT5
"
)
assert
model
[
"
RT1
"
].
has_parent
(
"
RT5
"
,
retrieve
=
False
)
assert
(
model
[
"
RT1
"
].
get_parent
(
assert
(
model
[
"
RT1
"
].
get_parent
(
"
RT5
"
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
)
"
RT5
"
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
)
...
@@ -509,5 +501,5 @@ R3:
...
@@ -509,5 +501,5 @@ R3:
assert
isinstance
(
r3
,
db
.
RecordType
)
assert
isinstance
(
r3
,
db
.
RecordType
)
for
par
in
[
"
R1
"
,
"
R2
"
]:
for
par
in
[
"
R1
"
,
"
R2
"
]:
# Until removal, both do the same
# Until removal, both do the same
assert
has_parent
(
r3
,
par
)
assert
r3
.
has_parent
(
par
,
retrieve
=
False
)
assert
r3
.
get_parent
(
par
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
assert
r3
.
get_parent
(
par
).
_flags
[
"
inheritance
"
]
==
db
.
OBLIGATORY
This diff is collapsed.
Click to expand it.
Henrik tom Wörden
@henrik
mentioned in issue
#103
·
2 years ago
mentioned in issue
#103
mentioned in issue #103
Toggle commit list
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