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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
511aeaa7
Commit
511aeaa7
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add unittest for json-schema parser
parent
96cb446d
No related branches found
No related tags found
2 merge requests
!39
Release 0.4.0
,
!33
F json schema datamodel
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
unittests/datamodel_string_properties.schema.json
+13
-0
13 additions, 0 deletions
unittests/datamodel_string_properties.schema.json
unittests/test_json_schema_model_parser.py
+48
-0
48 additions, 0 deletions
unittests/test_json_schema_model_parser.py
with
61 additions
and
0 deletions
unittests/datamodel_string_properties.schema.json
0 → 100644
+
13
−
0
View file @
511aeaa7
{
"title"
:
"Dataset"
,
"description"
:
""
,
"type"
:
"object"
,
"properties"
:
{
"title"
:
{
"type"
:
"string"
,
"description"
:
"full dataset title"
},
"campaign"
:
{
"type"
:
"string"
,
"description"
:
"FIXME"
},
"method"
:
{
"type"
:
"string"
,
"description"
:
"FIXME"
}
},
"required"
:
[
"title"
]
}
This diff is collapsed.
Click to expand it.
unittests/test_json_schema_model_parser.py
0 → 100644
+
48
−
0
View file @
511aeaa7
#
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2022 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2022 Florian Spreckelsen <f.spreckelsen@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
import
caosdb
as
db
from
caosadvancedtools.models.parser
import
parse_model_from_json_schema
def
test_rt_with_string_properties
():
"""
Test datamodel parsing of datamodel_string_properties.schema.json
"""
model
=
parse_model_from_json_schema
(
"
datamodel_string_properties.schema.json
"
)
assert
"
Dataset
"
in
model
dataset_rt
=
model
[
"
Dataset
"
]
assert
dataset
.
description
==
""
assert
len
(
dataset
.
get_properties
())
==
3
assert
dataset_rt
.
get_property
(
"
title
"
)
!=
None
assert
dataset_rt
.
get_property
(
"
campaign
"
)
!=
None
assert
dataset_rt
.
get_property
(
"
method
"
)
!=
None
title_prop
=
dataset_rt
.
get_property
(
"
title
"
)
assert
title_prop
.
datatype
==
db
.
TEXT
assert
dataset_rt
.
get_importance
(
title_prop
.
name
)
==
db
.
OBLIGATORY
campaign_prop
=
dataset_rt
.
get_property
(
"
campaign
"
)
assert
campaign_prop
.
datatype
==
db
.
TEXT
assert
dataset_rt
.
get_importance
(
campaign_prop
.
name
)
==
db
.
RECOMMENDED
method_prop
=
dataset_rt
.
get_property
(
"
method
"
)
assert
method_prop
.
datatype
==
db
.
TEXT
assert
dataset_rt
.
get_importance
(
method_prop
.
name
)
==
db
.
RECOMMENDED
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