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
6007fc62
Commit
6007fc62
authored
1 year ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Finish unittest
parent
97be7ef9
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
Pipeline
#42790
failed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_json_schema_exporter.py
+48
-0
48 additions, 0 deletions
unittests/test_json_schema_exporter.py
with
48 additions
and
0 deletions
unittests/test_json_schema_exporter.py
+
48
−
0
View file @
6007fc62
...
...
@@ -43,6 +43,7 @@ def _mock_execute_query(query_string, unique=False, **kwargs):
all_records
.
extend
(
other_type_records
)
referencing_type_rt
=
db
.
RecordType
(
name
=
"
ReferencingType
"
)
referencing_type_rt
.
add_property
(
name
=
other_type_rt
.
name
,
datatype
=
db
.
LIST
(
other_type_rt
.
name
))
referencing_type_records
=
db
.
Container
().
extend
([
db
.
Record
(
id
=
103
).
add_parent
(
referencing_type_rt
),
db
.
Record
(
id
=
104
,
name
=
"
referencing
"
).
add_parent
(
referencing_type_rt
)
...
...
@@ -458,6 +459,53 @@ def test_rt_with_references():
}
validate
(
example
,
schema
)
rt
=
db
.
RecordType
(
name
=
"
ReferenceofReferencesType
"
)
rt
.
add_property
(
name
=
"
RefRefProp
"
,
datatype
=
"
ReferencingType
"
)
schema
=
rtjs
(
rt
)
assert
"
RefRefProp
"
in
schema
[
"
properties
"
]
ref_ref
=
schema
[
"
properties
"
][
"
RefRefProp
"
]
assert
"
oneOf
"
in
ref_ref
assert
len
(
ref_ref
[
"
oneOf
"
])
==
2
enum_index
=
0
if
"
enum
"
not
in
ref_ref
[
"
oneOf
"
][
enum_index
]:
enum_index
=
1
-
enum_index
assert
len
(
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
2
assert
"
103
"
in
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
104, referencing
"
in
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
type
"
]
==
"
object
"
assert
"
OtherType
"
in
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
properties
"
]
assert
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
properties
"
][
"
OtherType
"
][
"
type
"
]
==
"
array
"
items
=
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
properties
"
][
"
OtherType
"
][
"
items
"
]
assert
"
oneOf
"
in
items
assert
len
(
items
[
"
oneOf
"
])
==
2
# same as above, we can't rely on the order
enum_index
=
0
if
"
enum
"
not
in
items
[
"
oneOf
"
][
enum_index
]:
enum_index
=
1
-
enum_index
assert
"
enum
"
in
items
[
"
oneOf
"
][
enum_index
]
assert
isinstance
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
],
list
)
assert
len
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
3
assert
"
100, otherA
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
101, otherB
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
102
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
other_type
=
items
[
"
oneOf
"
][
1
-
enum_index
]
assert
other_type
[
"
type
"
]
==
"
object
"
assert
"
IntegerProp
"
in
other_type
[
"
properties
"
]
assert
len
(
other_type
[
"
required
"
])
==
1
assert
"
IntegerProp
"
in
other_type
[
"
required
"
]
example
=
{
"
RefRefProp
"
:
{
"
OtherType
"
:
[
"
100, otherA
"
,
{
"
IntegerProp
"
:
12
}
]
}
}
validate
(
example
,
schema
)
rt
=
db
.
RecordType
()
rt
.
add_property
(
name
=
"
FileProp
"
,
datatype
=
db
.
FILE
)
...
...
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