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
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
Titouan Soulard
slapos
Commits
77733217
Commit
77733217
authored
Oct 06, 2022
by
Cédric Le Ninivin
Committed by
Titouan Soulard
Mar 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: Finish adding tests
parent
a510c252
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
6 deletions
+55
-6
slapos/test/recipe/test_request.py
slapos/test/recipe/test_request.py
+55
-6
No files found.
slapos/test/recipe/test_request.py
View file @
77733217
...
@@ -245,34 +245,83 @@ class RecipejIOTestMixin:
...
@@ -245,34 +245,83 @@ class RecipejIOTestMixin:
api_handler
.
request_payload_list
[
0
],
json
.
dumps
(
expected_request_body
))
api_handler
.
request_payload_list
[
0
],
json
.
dumps
(
expected_request_body
))
self
.
assertEqual
(
self
.
options
[
"connection-anything"
],
"done"
)
self
.
assertEqual
(
self
.
options
[
"connection-anything"
],
"done"
)
""" def test_return_not_ready(self):
def
test_return_not_ready
(
self
):
pass
self
.
instance_data
[
"connection_parameters"
]
=
self
.
connection_parameter_dict_empty
api_handler
=
APIRequestHandler
([
(
"/api/get"
,
json
.
dumps
(
self
.
instance_data
)),
])
self
.
options
[
'return'
]
=
'anything'
with
httmock
.
HTTMock
(
api_handler
.
request_handler
):
with
LogCapture
()
as
log
:
recipe
=
self
.
recipe
(
self
.
buildout
,
"request"
,
self
.
options
)
log
.
check
()
if
self
.
raises
:
self
.
assertRaises
(
KeyError
,
recipe
.
install
)
expected_request_body
=
{
"software_release_uri"
:
"foo.cfg"
,
"title"
:
"MyInstance"
,
"portal_type"
:
"Software Instance"
,
"compute_partition_id"
:
"slappartx12"
,
"state"
:
"started"
,
"compute_node_id"
:
"COMP-321"
,
"software_type"
:
"RootSoftwareInstance"
}
if
self
.
called_partition_parameter_kw
:
expected_request_body
[
"parameters"
]
=
json
.
dumps
(
self
.
called_partition_parameter_kw
)
self
.
assertEqual
(
api_handler
.
request_payload_list
[
0
],
json
.
dumps
(
expected_request_body
))
self
.
assertEqual
(
self
.
options
[
"connection-anything"
],
""
)
def
test_return_ready
(
self
):
def
test_return_ready
(
self
):
pass
api_handler
=
APIRequestHandler
([
"""
(
"/api/get"
,
json
.
dumps
(
self
.
instance_data
)),
])
self
.
options
[
'return'
]
=
'anything'
with
httmock
.
HTTMock
(
api_handler
.
request_handler
):
recipe
=
self
.
recipe
(
self
.
buildout
,
"request"
,
self
.
options
)
result
=
recipe
.
install
()
self
.
assertEqual
([],
result
)
expected_request_body
=
{
"software_release_uri"
:
"foo.cfg"
,
"title"
:
"MyInstance"
,
"portal_type"
:
"Software Instance"
,
"compute_partition_id"
:
"slappartx12"
,
"state"
:
"started"
,
"compute_node_id"
:
"COMP-321"
,
"software_type"
:
"RootSoftwareInstance"
}
if
self
.
called_partition_parameter_kw
:
expected_request_body
[
"parameters"
]
=
json
.
dumps
(
self
.
called_partition_parameter_kw
)
self
.
assertEqual
(
api_handler
.
request_payload_list
[
0
],
json
.
dumps
(
expected_request_body
))
self
.
assertEqual
(
self
.
options
[
"connection-anything"
],
"done"
)
self
.
assertIsInstance
(
self
.
options
[
'connection-anything'
],
str
)
class
RequestjIOTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
class
RequestjIOTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
recipe
=
request
.
Recipe
recipe
=
request
.
Recipe
connection_parameter_dict_empty
=
{}
connection_parameter_dict_empty
=
{}
connection_parameter_dict
=
{
"anything"
:
"done"
}
connection_parameter_dict
=
{
"anything"
:
"done"
}
called_partition_parameter_kw
=
None
called_partition_parameter_kw
=
None
raises
=
True
class
RequestjIOAPIOptionalTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
class
RequestjIOAPIOptionalTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
recipe
=
request
.
RequestOptional
recipe
=
request
.
RequestOptional
connection_parameter_dict_empty
=
{}
connection_parameter_dict_empty
=
{}
connection_parameter_dict
=
{
"anything"
:
"done"
}
connection_parameter_dict
=
{
"anything"
:
"done"
}
called_partition_parameter_kw
=
None
called_partition_parameter_kw
=
None
raises
=
False
class
RequestjIOAPIJSONEncodedTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
class
RequestjIOAPIJSONEncodedTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
recipe
=
request
.
RequestJSONEncoded
recipe
=
request
.
RequestJSONEncoded
connection_parameter_dict_empty
=
{}
connection_parameter_dict_empty
=
{}
connection_parameter_dict
=
{
"_"
:
'{"anything": "done"}'
}
connection_parameter_dict
=
{
"_"
:
'{"anything": "done"}'
}
called_partition_parameter_kw
=
{
"_"
:
"{}"
}
called_partition_parameter_kw
=
{
"_"
:
"{}"
}
raises
=
True
class
RequestjIOAPIOptionalJSONEncodedTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
class
RequestjIOAPIOptionalJSONEncodedTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
recipe
=
request
.
RequestOptionalJSONEncoded
recipe
=
request
.
RequestOptionalJSONEncoded
connection_parameter_dict_empty
=
{}
connection_parameter_dict_empty
=
{}
connection_parameter_dict
=
{
"_"
:
'{"anything": "done"}'
}
connection_parameter_dict
=
{
"_"
:
'{"anything": "done"}'
}
called_partition_parameter_kw
=
{
"_"
:
"{}"
}
called_partition_parameter_kw
=
{
"_"
:
"{}"
}
raises
=
False
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