Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos.core
Commits
1ac3ec59
Commit
1ac3ec59
authored
Jun 28, 2022
by
Thomas Gambier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: fix getSerialisation when some software_type has different serialisation
parent
a9ed7398
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
slapos/tests/test_util.py
slapos/tests/test_util.py
+9
-1
slapos/util.py
slapos/util.py
+3
-1
No files found.
slapos/tests/test_util.py
View file @
1ac3ec59
...
@@ -246,10 +246,12 @@ class TestUtil(unittest.TestCase):
...
@@ -246,10 +246,12 @@ class TestUtil(unittest.TestCase):
class
SoftwareReleaseSchemaTestXmlSerialisationMixin
:
class
SoftwareReleaseSchemaTestXmlSerialisationMixin
:
serialisation
=
SoftwareReleaseSerialisation
.
Xml
serialisation
=
SoftwareReleaseSerialisation
.
Xml
serialisation_alt
=
SoftwareReleaseSerialisation
.
JsonInXml
class
SoftwareReleaseSchemaTestJsonInXmlSerialisationMixin
:
class
SoftwareReleaseSchemaTestJsonInXmlSerialisationMixin
:
serialisation
=
SoftwareReleaseSerialisation
.
JsonInXml
serialisation
=
SoftwareReleaseSerialisation
.
JsonInXml
serialisation_alt
=
SoftwareReleaseSerialisation
.
Xml
class
SoftwareReleaseSchemaTestMixin
(
object
):
class
SoftwareReleaseSchemaTestMixin
(
object
):
...
@@ -257,6 +259,7 @@ class SoftwareReleaseSchemaTestMixin(object):
...
@@ -257,6 +259,7 @@ class SoftwareReleaseSchemaTestMixin(object):
"""
"""
software_url
=
None
# type: str
software_url
=
None
# type: str
serialisation
=
None
# type: SoftwareReleaseSerialisation
serialisation
=
None
# type: SoftwareReleaseSerialisation
serialisation_alt
=
None
# type: SoftwareReleaseSerialisation
def
test_software_schema
(
self
):
def
test_software_schema
(
self
):
...
@@ -269,6 +272,10 @@ class SoftwareReleaseSchemaTestMixin(object):
...
@@ -269,6 +272,10 @@ class SoftwareReleaseSchemaTestMixin(object):
schema
=
SoftwareReleaseSchema
(
self
.
software_url
,
None
)
schema
=
SoftwareReleaseSchema
(
self
.
software_url
,
None
)
self
.
assertEqual
(
schema
.
getSerialisation
(),
self
.
serialisation
)
self
.
assertEqual
(
schema
.
getSerialisation
(),
self
.
serialisation
)
def
test_serialisation_alternate_software_type
(
self
):
schema
=
SoftwareReleaseSchema
(
self
.
software_url
,
'alternate'
)
self
.
assertEqual
(
schema
.
getSerialisation
(),
self
.
serialisation_alt
)
def
test_instance_request_parameter_schema_default_software_type
(
self
):
def
test_instance_request_parameter_schema_default_software_type
(
self
):
schema
=
SoftwareReleaseSchema
(
self
.
software_url
,
None
)
schema
=
SoftwareReleaseSchema
(
self
.
software_url
,
None
)
self
.
assertTrue
(
schema
.
getInstanceRequestParameterSchemaURL
())
self
.
assertTrue
(
schema
.
getInstanceRequestParameterSchemaURL
())
...
@@ -307,7 +314,7 @@ class SoftwareReleaseSchemaTestMixin(object):
...
@@ -307,7 +314,7 @@ class SoftwareReleaseSchemaTestMixin(object):
instance_ok
=
{
'key'
:
'value'
,
'type'
:
'alternate'
}
instance_ok
=
{
'key'
:
'value'
,
'type'
:
'alternate'
}
schema
.
validateInstanceParameterDict
(
instance_ok
)
schema
.
validateInstanceParameterDict
(
instance_ok
)
if
self
.
serialisation
==
SoftwareReleaseSerialisation
.
JsonInXml
:
if
self
.
serialisation
_alt
==
SoftwareReleaseSerialisation
.
JsonInXml
:
# already serialized values are also tolerated
# already serialized values are also tolerated
schema
.
validateInstanceParameterDict
({
'_'
:
json
.
dumps
(
instance_ok
)})
schema
.
validateInstanceParameterDict
({
'_'
:
json
.
dumps
(
instance_ok
)})
...
@@ -357,6 +364,7 @@ class SoftwareReleaseSchemaTestFileSoftwareReleaseMixin(SoftwareReleaseSchemaTes
...
@@ -357,6 +364,7 @@ class SoftwareReleaseSchemaTestFileSoftwareReleaseMixin(SoftwareReleaseSchemaTes
"alternate"
:
{
"alternate"
:
{
"title"
:
"Alternate"
,
"title"
:
"Alternate"
,
"description"
:
"Alternate type"
,
"description"
:
"Alternate type"
,
"serialisation"
:
self
.
serialisation_alt
,
"request"
:
"instance-alternate-input-schema.json"
,
"request"
:
"instance-alternate-input-schema.json"
,
"response"
:
"instance-alternate-output-schema.json"
,
"response"
:
"instance-alternate-output-schema.json"
,
"index"
:
0
"index"
:
0
...
...
slapos/util.py
View file @
1ac3ec59
...
@@ -396,7 +396,9 @@ class SoftwareReleaseSchema(object):
...
@@ -396,7 +396,9 @@ class SoftwareReleaseSchema(object):
# type: () -> Optional[SoftwareReleaseSerialisation]
# type: () -> Optional[SoftwareReleaseSerialisation]
"""Returns the serialisation method used for parameters.
"""Returns the serialisation method used for parameters.
"""
"""
software_schema
=
self
.
getSoftwareSchema
()
software_schema
=
self
.
getSoftwareTypeSchema
()
if
software_schema
is
None
or
'serialisation'
not
in
software_schema
:
software_schema
=
self
.
getSoftwareSchema
()
if
software_schema
is
None
:
if
software_schema
is
None
:
return
None
return
None
return
SoftwareReleaseSerialisation
(
software_schema
[
'serialisation'
])
return
SoftwareReleaseSerialisation
(
software_schema
[
'serialisation'
])
...
...
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