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
335b7350
Commit
335b7350
authored
1 year ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
TST: Extend unittest
parent
c8c055c4
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.
,
!81
F schema export references
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_json_schema_exporter.py
+26
-2
26 additions, 2 deletions
unittests/test_json_schema_exporter.py
with
26 additions
and
2 deletions
unittests/test_json_schema_exporter.py
+
26
−
2
View file @
335b7350
...
...
@@ -270,8 +270,8 @@ def test_rt_with_list_props():
@patch
(
"
linkahead.execute_query
"
,
new
=
Mock
(
side_effect
=
_mock_execute_query
))
def
test_rt_with_references
():
"""
References and lists of references will come later, so test if
the errors
are thrown correctly.
"""
References and lists of references
to files
will come later, so test if
the errors
are thrown correctly.
"""
...
...
@@ -280,11 +280,35 @@ def test_rt_with_references():
schema
=
rtjs
(
rt
)
props
=
schema
[
"
properties
"
]
assert
"
RefProp
"
in
props
assert
"
enum
"
in
props
[
"
RefProp
"
]
assert
isinstance
(
props
[
"
RefProp
"
][
"
enum
"
],
list
)
assert
len
(
props
[
"
RefProp
"
][
"
enum
"
])
==
len
(
db
.
execute_query
(
"
SELECT name, id FROM RECORD
"
))
+
len
(
db
.
execute_query
(
"
SELECT name, id FROM FILE
"
))
assert
"
oneOf
"
not
in
props
[
"
RefProp
"
]
rt
=
db
.
RecordType
()
rt
.
add_property
(
name
=
"
RefProp
"
,
datatype
=
"
OtherType
"
)
schema
=
rtjs
(
rt
)
props
=
schema
[
"
properties
"
]
assert
"
RefProp
"
in
props
assert
"
oneOf
"
in
props
[
"
RefProp
"
]
assert
len
(
props
[
"
RefProp
"
][
"
oneOf
"
])
==
2
enum_index
=
0
if
"
enum
"
not
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
]:
# We can't really require the order here, so we just know that one of
# the two elements must be the enum, the other the object.
enum_index
=
1
-
enum_index
assert
"
enum
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
]
assert
isinstance
(
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
],
list
)
assert
len
(
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
3
assert
"
100, otherA
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
101, otherB
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
102
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
# the other element of oneOf is the OtherType object
assert
props
[
"
RefProp
"
][
"
oneOf
"
][
1
-
enum_index
][
"
type
"
]
==
"
object
"
rt
=
db
.
RecordType
()
rt
.
add_property
(
name
=
"
RefProp
"
,
datatype
=
db
.
LIST
(
db
.
REFERENCE
))
...
...
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