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
6f420b3b
Verified
Commit
6f420b3b
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: More description in JSX
parent
f17eb65d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!89
ENH: JsonSchemaExporter accepts do_not_create parameter.
,
!88
jsex / yaml parser
Pipeline
#44091
failed
1 year 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
src/caosadvancedtools/json_schema_exporter.py
+2
-0
2 additions, 0 deletions
src/caosadvancedtools/json_schema_exporter.py
unittests/test_json_schema_exporter.py
+22
-17
22 additions, 17 deletions
unittests/test_json_schema_exporter.py
with
24 additions
and
17 deletions
src/caosadvancedtools/json_schema_exporter.py
+
2
−
0
View file @
6f420b3b
...
@@ -368,6 +368,8 @@ class JsonSchemaExporter:
...
@@ -368,6 +368,8 @@ class JsonSchemaExporter:
schema
[
"
required
"
]
=
self
.
_make_required_list
(
rt
)
schema
[
"
required
"
]
=
self
.
_make_required_list
(
rt
)
schema
[
"
additionalProperties
"
]
=
self
.
_additional_properties
schema
[
"
additionalProperties
"
]
=
self
.
_additional_properties
if
rt
.
description
:
schema
[
"
description
"
]
=
rt
.
description
if
rt
.
name
:
if
rt
.
name
:
schema
[
"
title
"
]
=
rt
.
name
schema
[
"
title
"
]
=
rt
.
name
...
...
This diff is collapsed.
Click to expand it.
unittests/test_json_schema_exporter.py
+
22
−
17
View file @
6f420b3b
...
@@ -36,14 +36,26 @@ from unittest.mock import Mock, patch
...
@@ -36,14 +36,26 @@ from unittest.mock import Mock, patch
from
caosadvancedtools.json_schema_exporter
import
recordtype_to_json_schema
as
rtjs
from
caosadvancedtools.json_schema_exporter
import
recordtype_to_json_schema
as
rtjs
from
caosadvancedtools.models.parser
import
parse_model_from_string
from
caosadvancedtools.models.parser
import
parse_model_from_string
RT1
=
parse_model_from_string
(
"""
GLOBAL_MODEL
=
parse_model_from_string
(
"""
RT1:
RT1:
description: some description
description: some description
obligatory_properties:
obligatory_properties:
some_date:
some_date:
datatype: DATETIME
datatype: DATETIME
description: Just some date
description: Just some date
"""
).
get_deep
(
"
RT1
"
)
RT21:
obligatory_properties:
RT1:
datatype: LIST<RT1>
RT31:
obligatory_properties:
RT1:
"""
)
RT1
=
GLOBAL_MODEL
.
get_deep
(
"
RT1
"
)
RT21
=
GLOBAL_MODEL
.
get_deep
(
"
RT21
"
)
RT31
=
GLOBAL_MODEL
.
get_deep
(
"
RT31
"
)
def
_mock_execute_query
(
query_string
,
unique
=
False
,
**
kwargs
):
def
_mock_execute_query
(
query_string
,
unique
=
False
,
**
kwargs
):
...
@@ -82,24 +94,15 @@ def _mock_execute_query(query_string, unique=False, **kwargs):
...
@@ -82,24 +94,15 @@ def _mock_execute_query(query_string, unique=False, **kwargs):
elif
query_string
==
"
FIND RECORDTYPE WITH name=
'
RT1
'"
and
unique
is
True
:
elif
query_string
==
"
FIND RECORDTYPE WITH name=
'
RT1
'"
and
unique
is
True
:
return
RT1
return
RT1
elif
query_string
==
"
FIND RECORDTYPE WITH name=
'
RT21
'"
and
unique
is
True
:
elif
query_string
==
"
FIND RECORDTYPE WITH name=
'
RT21
'"
and
unique
is
True
:
model_str
=
"""
return
RT21
RT1:
elif
query_string
==
"
FIND RECORDTYPE WITH name=
'
RT31
'"
and
unique
is
True
:
RT21:
return
RT31
obligatory_properties:
RT1:
datatype: LIST<RT1>
RT3:
obligatory_properties:
RT21:
"""
model
=
parse_model_from_string
(
model_str
)
return
model
.
get_deep
(
"
RT21
"
)
elif
query_string
==
"
SELECT name, id FROM RECORD
"
:
elif
query_string
==
"
SELECT name, id FROM RECORD
"
:
return
all_records
return
all_records
elif
query_string
==
"
SELECT name, id FROM FILE
"
:
elif
query_string
==
"
SELECT name, id FROM FILE
"
:
return
all_files
return
all_files
else
:
else
:
#
print(f"Query string: {query_string}")
print
(
f
"
Query string:
{
query_string
}
"
)
if
unique
is
True
:
if
unique
is
True
:
return
db
.
Entity
()
return
db
.
Entity
()
return
db
.
Container
()
return
db
.
Container
()
...
@@ -642,6 +645,7 @@ RT2:
...
@@ -642,6 +645,7 @@ RT2:
"
some_date
"
"
some_date
"
],
],
"
additionalProperties
"
: true,
"
additionalProperties
"
: true,
"
description
"
:
"
some description
"
,
"
title
"
:
"
RT1
"
,
"
title
"
:
"
RT1
"
,
"
properties
"
: {
"
properties
"
: {
"
some_date
"
: {
"
some_date
"
: {
...
@@ -658,8 +662,7 @@ RT2:
...
@@ -658,8 +662,7 @@ RT2:
]
]
}
}
},
},
"
$schema
"
:
"
https://json-schema.org/draft/2020-12/schema
"
,
"
$schema
"
:
"
https://json-schema.org/draft/2020-12/schema
"
"
description
"
:
"
some description
"
}
"""
}
"""
# Second test: with reference
# Second test: with reference
rt2_deep
=
model
.
get_deep
(
"
RT2
"
)
rt2_deep
=
model
.
get_deep
(
"
RT2
"
)
...
@@ -688,6 +691,7 @@ RT2:
...
@@ -688,6 +691,7 @@ RT2:
"
some_date
"
"
some_date
"
],
],
"
additionalProperties
"
: true,
"
additionalProperties
"
: true,
"
description
"
:
"
some description
"
,
"
title
"
:
"
Create new
"
,
"
title
"
:
"
Create new
"
,
"
properties
"
: {
"
properties
"
: {
"
some_date
"
: {
"
some_date
"
: {
...
@@ -958,6 +962,7 @@ RT3:
...
@@ -958,6 +962,7 @@ RT3:
==
"
{
'
RT1
'
: {
'
ui:widget
'
:
'
checkboxes
'
,
'
ui:options
'
: {
'
inline
'
: True}}}
"
)
==
"
{
'
RT1
'
: {
'
ui:widget
'
:
'
checkboxes
'
,
'
ui:options
'
: {
'
inline
'
: True}}}
"
)
@patch
(
"
linkahead.execute_query
"
,
new
=
Mock
(
side_effect
=
_mock_execute_query
))
def
test_schema_customization_with_dicts
():
def
test_schema_customization_with_dicts
():
"""
Testing the ``additional_json_schema`` and ``additional_ui_schema`` parameters.
"""
"""
Testing the ``additional_json_schema`` and ``additional_ui_schema`` parameters.
"""
model_str
=
"""
model_str
=
"""
...
...
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