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
1f0301ed
Commit
1f0301ed
authored
2 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Finalize integration tests for json-schema datamodel parser
parent
cdbebd84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!39
Release 0.4.0
,
!33
F json schema datamodel
Pipeline
#20742
passed
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
integrationtests/test_datamodel.schema.json
+34
-1
34 additions, 1 deletion
integrationtests/test_datamodel.schema.json
integrationtests/test_json_schema_datamodel_parser.py
+45
-2
45 additions, 2 deletions
integrationtests/test_json_schema_datamodel_parser.py
with
79 additions
and
3 deletions
integrationtests/test_datamodel.schema.json
+
34
−
1
View file @
1f0301ed
...
...
@@ -47,6 +47,39 @@
{
"title"
:
"TestTypeWithLists"
,
"type"
:
"object"
,
"properties"
:
{}
"properties"
:
{
"string_list"
:
{
"type"
:
"array"
,
"description"
:
"A list of words"
,
"items"
:
{
"type"
:
"string"
}
},
"named_int_list"
:
{
"type"
:
"array"
,
"title"
:
"NamedIntList"
,
"items"
:
{
"type"
:
"integer"
}
},
"ListRecordType"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"properties"
:
{}
}
},
"NamedReferenceList"
:
{
"type"
:
"array"
,
"items"
:
{
"title"
:
"ReferencedListTypeWithName"
,
"type"
:
"object"
,
"description"
:
"Referenced by a named list-of-references property"
,
"properties"
:
{
"double_prop"
:
{}
}
}
},
"ListNumberEnum"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"number"
,
"enum"
:
[
1.1
,
2.2
,
3.3
]
}
}
}
}
]
This diff is collapsed.
Click to expand it.
integrationtests/test_json_schema_datamodel_parser.py
+
45
−
2
View file @
1f0301ed
...
...
@@ -120,8 +120,10 @@ def test_json_parsed_datamodel():
enum_type
=
db
.
execute_query
(
f
"
FIND RECORDTYPE
{
enum_type_name
}
"
,
unique
=
True
)
assert
len
(
enum_type
.
properties
)
==
0
assert
len
(
db
.
execute_query
(
f
"
FIND RECORD
{
enum_type_name
}
"
))
==
len
(
enum_names
)
enum_records
=
db
.
execute_query
(
f
"
FIND RECORD
{
enum_type_name
}
"
)
assert
len
(
enum_records
)
==
len
(
enum_names
)
for
rec
in
enum_records
:
assert
rec
.
name
in
enum_names
assert
rt2
.
get_property
(
enum_type_name
)
is
not
None
assert
rt2
.
get_property
(
enum_type_name
).
is_reference
()
assert
rt2
.
get_property
(
enum_type_name
).
name
==
enum_type
.
name
...
...
@@ -129,3 +131,44 @@ def test_json_parsed_datamodel():
# Recordtype with lists
rt3
=
db
.
execute_query
(
"
FIND RECORDTYPE TestTypeWithLists
"
,
unique
=
True
)
assert
rt3
.
get_property
(
"
string_list
"
)
is
not
None
assert
rt3
.
get_property
(
"
string_list
"
).
datatype
==
db
.
LIST
(
db
.
TEXT
)
string_list_prop
=
db
.
Property
(
name
=
"
string_list
"
).
retrieve
()
assert
string_list_prop
.
description
==
"
A list of words
"
assert
string_list_prop
.
datatype
==
db
.
LIST
(
db
.
TEXT
)
assert
string_list_prop
.
id
==
rt3
.
get_property
(
"
string_list
"
).
id
assert
rt3
.
get_property
(
"
NamedIntList
"
)
is
not
None
assert
rt3
.
get_property
(
"
NamedIntList
"
).
datatype
==
db
.
LIST
(
db
.
INTEGER
)
# This is a list of a plain references to a specific type
list_rt
=
db
.
execute_query
(
"
FIND RECORDTYPE ListRecordType
"
,
unique
=
True
)
assert
len
(
list_rt
.
properties
)
==
0
assert
rt3
.
get_property
(
list_rt
.
name
)
is
not
None
assert
rt3
.
get_property
(
list_rt
.
name
).
is_reference
()
assert
rt3
.
get_property
(
list_rt
.
name
).
datatype
==
db
.
LIST
(
list_rt
)
assert
rt3
.
get_property
(
list_rt
.
name
).
id
==
list_rt
.
id
# This is a list property of its own, referencing another separate RT
referenced_list_rt
=
db
.
execute_query
(
"
FIND RECORDTYPE ReferencedListTypeWithName
"
,
unique
=
True
)
assert
referenced_list_rt
.
description
==
"
Referenced by a named list-of-references property
"
assert
referenced_list_rt
.
get_property
(
"
double_prop
"
)
is
not
None
assert
(
referenced_list_rt
.
get_property
(
"
double_prop
"
).
id
==
rt1
.
get_property
(
"
double_prop
"
).
id
)
assert
rt3
.
get_property
(
"
NamedReferenceList
"
)
is
not
None
assert
rt3
.
get_property
(
"
NamedReferenceList
"
).
is_reference
()
assert
rt3
.
get_property
(
"
NamedReferenceList
"
).
datatype
==
db
.
LIST
(
referenced_list_rt
)
assert
rt3
.
get_property
(
"
NamedReferenceList
"
).
id
!=
referenced_list_rt
.
id
enum_type
=
db
.
execute_query
(
"
FIND RECORDTYPE ListNumberEnum
"
,
unique
=
True
)
assert
len
(
enum_type
.
properties
)
==
0
enum_names
=
[
"
1.1
"
,
"
2.2
"
,
"
3.3
"
]
enum_records
=
db
.
execute_query
(
"
FIND RECORD ListNumberEnum
"
)
assert
len
(
enum_records
)
==
len
(
enum_names
)
for
rec
in
enum_records
:
assert
rec
.
name
in
enum_names
assert
rt3
.
get_property
(
enum_type
.
name
)
is
not
None
assert
rt3
.
get_property
(
enum_type
.
name
).
datatype
==
db
.
LIST
(
enum_type
)
assert
rt3
.
get_property
(
enum_type
.
name
).
id
==
enum_type
.
id
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