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
51e616a6
Commit
51e616a6
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Extend unit tests for other atomic datatypes
parent
3866f798
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!39
Release 0.4.0
,
!33
F json schema datamodel
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unittests/json-schema-models/datamodel_atomic_properties.schema.json
+22
-0
22 additions, 0 deletions
...son-schema-models/datamodel_atomic_properties.schema.json
unittests/test_json_schema_model_parser.py
+52
-1
52 additions, 1 deletion
unittests/test_json_schema_model_parser.py
with
74 additions
and
1 deletion
unittests/json-schema-models/datamodel_atomic_properties.schema.json
0 → 100644
+
22
−
0
View file @
51e616a6
[
{
"title"
:
"Dataset1"
,
"description"
:
"Some description"
,
"type"
:
"object"
,
"properties"
:
{
"title"
:
{
"type"
:
"string"
,
"description"
:
"full dataset title"
},
"campaign"
:
{
"type"
:
"string"
,
"description"
:
"FIXME"
},
"1"
:
{
"type"
:
"number"
,
"description"
:
"Some float property"
}
},
"required"
:
[
"title"
,
"1"
]
},
{
"title"
:
"Dataset2"
,
"type"
:
"object"
,
"properties"
:
{
"date"
:
{
"type"
:
"string"
,
"format"
:
"date-time"
},
"integer"
:
{
"type"
:
"integer"
,
"description"
:
"Some integer property"
},
"boolean"
:
{
"type"
:
"boolean"
}
}
}
]
This diff is collapsed.
Click to expand it.
unittests/test_json_schema_model_parser.py
+
52
−
1
View file @
51e616a6
...
...
@@ -33,9 +33,11 @@ def test_rt_with_string_properties():
model
=
parse_model_from_json_schema
(
os
.
path
.
join
(
FILEPATH
,
"
./
datamodel_string_properties.schema.json
"
))
"
datamodel_string_properties.schema.json
"
))
assert
"
Dataset
"
in
model
dataset_rt
=
model
[
"
Dataset
"
]
assert
isinstance
(
dataset_rt
,
db
.
RecordType
)
assert
dataset_rt
.
name
==
"
Dataset
"
assert
dataset_rt
.
description
==
""
assert
len
(
dataset_rt
.
get_properties
())
==
3
...
...
@@ -54,3 +56,52 @@ def test_rt_with_string_properties():
method_prop
=
dataset_rt
.
get_property
(
"
method
"
)
assert
method_prop
.
datatype
==
db
.
TEXT
assert
dataset_rt
.
get_importance
(
method_prop
.
name
)
==
db
.
RECOMMENDED
def
test_datamodel_with_atomic_properties
():
"""
Test read-in of two separate record types with atomic-typed properties.
"""
# @author Florian Spreckelsen
# @date 2022-02-18
model
=
parse_model_from_json_schema
(
os
.
path
.
join
(
FILEPATH
,
"
datamodel_atomic_properties.schema.json
"
))
assert
"
Dataset1
"
in
model
assert
"
Dataset2
"
in
model
rt1
=
model
[
"
Dataset1
"
]
assert
isinstance
(
rt1
,
db
.
RecordType
)
assert
rt
.
name
==
"
Dataset1
"
assert
rt1
.
description
==
"
Some description
"
assert
len
(
rt1
.
get_properties
())
==
3
assert
rt1
.
get_property
(
"
title
"
)
is
not
None
assert
rt1
.
get_property
(
"
campaign
"
)
is
not
None
assert
rt1
.
get_property
(
"
1
"
)
is
not
None
title_prop
=
rt1
.
get_property
(
"
title
"
)
assert
title_prop
.
datatype
==
db
.
TEXT
assert
rt1
.
get_importance
(
title_prop
.
name
)
==
db
.
OBLIGATORY
campaign_prop
=
rt1
.
get_property
(
"
campaign
"
)
assert
campaign_prop
.
datatype
==
db
.
TEXT
assert
rt1
.
get_importance
(
campaign_prop
.
name
)
==
db
.
RECOMMENDED
float_prop
=
rt1
.
get_property
(
"
1
"
)
assert
float_prop
.
datatype
==
db
.
DOUBLE
assert
rt1
.
get_importance
(
float_prop
.
name
)
==
db
.
OBLIGATORY
rt2
=
model
[
"
Dataset2
"
]
assert
isinstance
(
rt2
,
db
.
RecordType
)
assert
rt2
.
name
==
"
Dataset2
"
assert
not
rt2
.
description
assert
len
(
rt2
.
get_properties
())
==
3
date_prop
=
rt2
.
get_property
(
"
date
"
)
assert
date_prop
.
datatype
==
db
.
DATETIME
int_prop
=
rt2
.
get_property
(
"
integer
"
)
assert
int_prop
.
datatype
==
db
.
INTEGER
assert
int_prop
.
description
==
"
Some integer property
"
bool_prop
=
rt2
.
get_property
(
"
boolean
"
)
assert
bool_prop
.
datatype
==
db
.
BOOLEAN
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