Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos
Commits
dae3ad01
Commit
dae3ad01
authored
Mar 19, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
slapos.test: Test if software.cfg.json don't have duplicated entries
See merge request
!1552
parents
35247982
9bc6a32d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
slapos/test/test_json_schema.py
slapos/test/test_json_schema.py
+13
-3
No files found.
slapos/test/test_json_schema.py
View file @
dae3ad01
...
...
@@ -45,6 +45,10 @@ def createInstanceParameterSchemaValidatorTest(path):
"http://json-schema.org/draft-04/schema#"
:
jsonschema
.
Draft4Validator
,
"http://json-schema.org/draft-06/schema#"
:
jsonschema
.
Draft6Validator
,
"http://json-schema.org/draft-07/schema#"
:
jsonschema
.
Draft7Validator
,
"http://json-schema.org/draft/2019-09/schema"
:
jsonschema
.
Draft201909Validator
,
"http://json-schema.org/draft/2019-09/schema#"
:
jsonschema
.
Draft201909Validator
,
"http://json-schema.org/draft/2020-12/schema"
:
jsonschema
.
Draft202012Validator
,
"http://json-schema.org/draft/2020-12/schema#"
:
jsonschema
.
Draft202012Validator
,
}
def
run
(
self
,
*
args
,
**
kwargs
):
with
open
(
path
,
"r"
)
as
json_file
:
...
...
@@ -55,7 +59,6 @@ def createInstanceParameterSchemaValidatorTest(path):
validator
.
check_schema
(
json_dict
)
return
run
def
createSoftwareCfgValidatorTest
(
path
,
software_cfg_schema
):
# Test that software json follows the schema for softwares json,
# which is defined in schema.json in this directory
...
...
@@ -64,13 +67,20 @@ def createSoftwareCfgValidatorTest(path, software_cfg_schema):
schema
=
json
.
load
(
json_file
)
jsonschema
.
validate
(
schema
,
software_cfg_schema
)
_viewed_software_type
=
[]
# also make sure request and response schemas can be resolved
schema
.
setdefault
(
'$id'
,
'file://'
+
path
)
resolver
=
jsonschema
.
RefResolver
.
from_schema
(
schema
)
for
software_type_definition
in
six
.
itervalue
s
(
schema
[
'software-type'
]):
for
key
,
software_type_definition
in
six
.
iteritem
s
(
schema
[
'software-type'
]):
resolver
.
resolve
(
software_type_definition
[
'request'
])
resolver
.
resolve
(
software_type_definition
[
'response'
])
# Ensure there inst a duplicated entry.
_software_type_tuple
=
(
software_type_definition
.
get
(
"software-type"
,
key
),
software_type_definition
.
get
(
"shared"
,
False
))
assert
_software_type_tuple
not
in
_viewed_software_type
,
\
"Duplicated software release on %s, shared: %s"
%
_software_type_tuple
_viewed_software_type
.
append
(
_software_type_tuple
)
return
run
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment