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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
slapos
Commits
751acfa5
Commit
751acfa5
authored
Oct 11, 2022
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: Add test with jIO API that state is correctly propagated
parent
9c1881fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
slapos/test/recipe/test_request.py
slapos/test/recipe/test_request.py
+62
-0
No files found.
slapos/test/recipe/test_request.py
View file @
751acfa5
...
@@ -353,6 +353,68 @@ class RecipejIOTestMixin:
...
@@ -353,6 +353,68 @@ class RecipejIOTestMixin:
content_list
=
f
.
read
().
splitlines
()
content_list
=
f
.
read
().
splitlines
()
self
.
assertEqual
(
sorted
(
content_list
),
[
'MyInstance'
,
'MyInstance2'
])
self
.
assertEqual
(
sorted
(
content_list
),
[
'MyInstance'
,
'MyInstance2'
])
def
test_requester_stopped_state_propagated
(
self
):
api_handler
=
APIRequestHandler
([
(
"/api/get"
,
json
.
dumps
(
self
.
instance_data
)),
])
self
.
options
[
'return'
]
=
'anything'
self
.
buildout
[
'slap-connection'
][
'requested'
]
=
'stopped'
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"
:
"stopped"
,
"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
)
self
.
assertEqual
(
api_handler
.
sequence_list
,
[
"/api/post/"
])
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
transaction_file_path
))
with
open
(
self
.
transaction_file_path
,
'r'
)
as
f
:
content_list
=
f
.
read
().
splitlines
()
self
.
assertEqual
(
sorted
(
content_list
),
[
'MyInstance'
])
def
test_requester_destroyed_state_not_propagated
(
self
):
api_handler
=
APIRequestHandler
([
(
"/api/get"
,
json
.
dumps
(
self
.
instance_data
)),
])
self
.
options
[
'return'
]
=
'anything'
self
.
buildout
[
'slap-connection'
][
'requested'
]
=
'destroyed'
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
)
self
.
assertEqual
(
api_handler
.
sequence_list
,
[
"/api/post/"
])
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
transaction_file_path
))
with
open
(
self
.
transaction_file_path
,
'r'
)
as
f
:
content_list
=
f
.
read
().
splitlines
()
self
.
assertEqual
(
sorted
(
content_list
),
[
'MyInstance'
])
class
RequestjIOTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
class
RequestjIOTest
(
RecipejIOTestMixin
,
unittest
.
TestCase
):
recipe
=
request
.
Recipe
recipe
=
request
.
Recipe
connection_parameter_dict_empty
=
{}
connection_parameter_dict_empty
=
{}
...
...
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