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
a94319fe
Commit
a94319fe
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Add integration tests for references and enums
parent
042ae3c6
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
#20741
passed
3 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
-3
34 additions, 3 deletions
integrationtests/test_datamodel.schema.json
integrationtests/test_json_schema_datamodel_parser.py
+60
-0
60 additions, 0 deletions
integrationtests/test_json_schema_datamodel_parser.py
with
94 additions
and
3 deletions
integrationtests/test_datamodel.schema.json
+
34
−
3
View file @
a94319fe
...
...
@@ -4,14 +4,45 @@
"description"
:
"RecordType with scalar atomic properties"
,
"type"
:
"object"
,
"properties"
:
{
"simple_text_prop"
:
{
"type"
:
"string"
}
"simple_text_prop"
:
{
"type"
:
"string"
},
"int_prop_with_name"
:
{
"type"
:
"integer"
,
"title"
:
"IntegerProperty"
},
"double_prop"
:
{
"type"
:
"number"
,
"description"
:
"Some generic double-valued property"
},
"bool_prop"
:
{
"type"
:
"boolean"
},
"datetime_prop"
:
{
"type"
:
"string"
,
"format"
:
"date-time"
},
"date_prop"
:
{
"type"
:
"string"
,
"format"
:
"date"
}
},
"required"
:
[
"simple_text_prop"
]
"required"
:
[
"simple_text_prop"
,
"double_prop"
]
},
{
"title"
:
"TestTypeWithReferencesAndEnum"
,
"type"
:
"object"
,
"properties"
:
{}
"properties"
:
{
"TestTypeWithAtomicProps"
:
{},
"OtherReference"
:
{
"type"
:
"object"
,
"description"
:
"Some generic refernced RecordType"
,
"properties"
:
{}
},
"named_refernce"
:
{
"type"
:
"object"
,
"title"
:
"NamedReference"
,
"properties"
:
{
"simple_text_prop"
:
{}
}
},
"string_enum"
:
{
"type"
:
"string"
,
"enum"
:
[
"StringEnumA"
,
"StringEnumB"
,
"StringEnumC"
]
},
"named_enum"
:
{
"type"
:
"string"
,
"title"
:
"NamedEnum"
,
"enum"
:
[
"NameA"
,
"NameB"
,
"NameC"
]
}
}
},
{
"title"
:
"TestTypeWithLists"
,
...
...
This diff is collapsed.
Click to expand it.
integrationtests/test_json_schema_datamodel_parser.py
+
60
−
0
View file @
a94319fe
...
...
@@ -63,9 +63,69 @@ def test_json_parsed_datamodel():
assert
rt1
.
get_property
(
"
simple_text_prop
"
).
datatype
==
db
.
TEXT
assert
rt1
.
get_importance
(
"
simple_text_prop
"
)
==
db
.
OBLIGATORY
assert
rt1
.
get_property
(
"
IntegerProperty
"
)
is
not
None
assert
rt1
.
get_property
(
"
IntegerProperty
"
).
datatype
==
db
.
INTEGER
assert
rt1
.
get_importance
(
"
IntegerProperty
"
)
==
db
.
RECOMMENDED
assert
rt1
.
get_property
(
"
double_prop
"
)
is
not
None
assert
rt1
.
get_property
(
"
double_prop
"
).
datatype
==
db
.
DOUBLE
assert
rt1
.
get_importance
(
"
double_prop
"
)
==
db
.
OBLIGATORY
assert
(
db
.
Property
(
name
=
"
double_prop
"
).
retrieve
().
description
==
"
Some generic double-valued property
"
)
further_props
=
[
(
"
bool_prop
"
,
db
.
BOOLEAN
),
(
"
datetime_prop
"
,
db
.
DATETIME
),
(
"
date_prop
"
,
db
.
DATETIME
)
]
for
name
,
dtype
in
further_props
:
assert
rt1
.
get_property
(
name
)
is
not
None
assert
rt1
.
get_property
(
name
).
datatype
==
dtype
assert
rt1
.
get_importance
(
name
)
==
db
.
RECOMMENDED
# RecordType with references and enums
rt2
=
db
.
execute_query
(
"
FIND RECORDTYPE TestTypeWithReferencesAndEnum
"
,
unique
=
True
)
assert
rt2
.
get_property
(
rt1
.
name
)
is
not
None
assert
rt2
.
get_property
(
rt1
.
name
).
is_reference
()
assert
rt2
.
get_property
(
rt1
.
name
).
name
==
rt1
.
name
assert
rt2
.
get_property
(
rt1
.
name
).
id
==
rt1
.
id
other_ref_type
=
db
.
execute_query
(
"
FIND RECORDTYPE OtherReference
"
,
unique
=
True
)
assert
rt2
.
get_property
(
other_ref_type
.
name
)
is
not
None
assert
rt2
.
get_property
(
other_ref_type
.
name
).
is_reference
()
assert
rt2
.
get_property
(
other_ref_type
.
name
).
name
==
other_ref_type
.
name
assert
rt2
.
get_property
(
other_ref_type
.
name
).
id
==
other_ref_type
.
id
assert
other_ref_type
.
description
==
"
Some generic refernced RecordType
"
assert
len
(
other_ref_type
.
properties
)
==
0
named_ref_type
=
db
.
execute_query
(
"
FIND RECORDTYPE NamedReference
"
,
unique
=
True
)
assert
rt2
.
get_property
(
named_ref_type
.
name
)
is
not
None
assert
rt2
.
get_property
(
named_ref_type
.
name
).
is_reference
()
assert
rt2
.
get_property
(
named_ref_type
.
name
).
name
==
named_ref_type
.
name
assert
rt2
.
get_property
(
named_ref_type
.
name
).
id
==
named_ref_type
.
id
assert
named_ref_type
.
get_property
(
"
simple_text_prop
"
)
is
not
None
assert
(
named_ref_type
.
get_property
(
"
simple_text_prop
"
).
id
==
rt1
.
get_property
(
"
simple_text_prop
"
).
id
)
assert
(
named_ref_type
.
get_property
(
"
simple_text_prop
"
).
datatype
==
rt1
.
get_property
(
"
simple_text_prop
"
).
datatype
)
enums
=
{
"
string_enum
"
:
[
"
StringEnumA
"
,
"
StringEnumB
"
,
"
StringEnumC
"
],
"
NamedEnum
"
:
[
"
NameA
"
,
"
NameB
"
,
"
NameC
"
]
}
for
enum_type_name
,
enum_names
in
enums
.
items
():
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
)
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
assert
rt2
.
get_property
(
enum_type_name
).
id
==
enum_type
.
id
# Recordtype with lists
rt3
=
db
.
execute_query
(
"
FIND RECORDTYPE TestTypeWithLists
"
,
unique
=
True
)
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