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
Eric Zheng
slapos.core
Commits
61eeec57
Commit
61eeec57
authored
May 21, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialise Computer.PUT testing.
parent
d913e5e5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
235 additions
and
1 deletion
+235
-1
master/bt5/vifib_slapos_rest_api_v1_test/PathTemplateItem/computer_module/template_computer.xml
...st/PathTemplateItem/computer_module/template_computer.xml
+74
-0
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+159
-0
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
+1
-1
master/bt5/vifib_slapos_rest_api_v1_test/bt/template_path_list
...r/bt5/vifib_slapos_rest_api_v1_test/bt/template_path_list
+1
-0
No files found.
master/bt5/vifib_slapos_rest_api_v1_test/PathTemplateItem/computer_module/template_computer.xml
0 → 100644
View file @
61eeec57
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Computer"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Access_contents_information_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Author
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Add_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Modify_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_View_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Author
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
template_computer
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Computer
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
View file @
61eeec57
...
@@ -1385,3 +1385,162 @@ class TestGET_discovery(VifibSlaposRestAPIV1Mixin):
...
@@ -1385,3 +1385,162 @@ class TestGET_discovery(VifibSlaposRestAPIV1Mixin):
self
.
assertCacheControlHeader
()
self
.
assertCacheControlHeader
()
self
.
assertResponseJson
()
self
.
assertResponseJson
()
self
.
assertAPIDiscoveryDict
()
self
.
assertAPIDiscoveryDict
()
class
TestComputerPUT
(
VifibSlaposRestAPIV1MixinBase
):
def
createComputer
(
self
):
computer
=
self
.
cloneByPath
(
'computer_module/template_computer'
)
computer
.
edit
(
reference
=
'C'
+
self
.
test_random_id
)
computer
.
validate
()
computer
.
manage_setLocalRoles
(
computer
.
getReference
(),
[
'Assignor'
])
transaction
.
commit
()
computer
.
recursiveImmediateReindexObject
()
transaction
.
commit
()
return
computer
def
afterSetUp
(
self
):
super
(
TestComputerPUT
,
self
).
afterSetUp
()
self
.
computer
=
self
.
createComputer
()
self
.
computer_reference
=
self
.
computer
.
getReference
()
self
.
computer_put_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
computer
.
Computer_updateFromJson
=
Simulator
(
self
.
computer_put_simulator
,
'Computer_updateFromJson'
)
transaction
.
commit
()
def
beforeTearDown
(
self
):
super
(
TestComputerPUT
,
self
).
beforeTearDown
()
if
os
.
path
.
exists
(
self
.
computer_put_simulator
):
os
.
unlink
(
self
.
computer_put_simulator
)
def
assertComputerPUTSimulator
(
self
,
l
):
stored
=
eval
(
open
(
self
.
computer_put_simulator
).
read
())
self
.
assertEqual
(
stored
,
l
)
# check that method is called with strings, not unicodes
for
l_
in
l
[
0
][
'recargs'
][
0
].
itervalues
():
for
el
in
l_
:
self
.
assertEqual
(
set
([
type
(
q
)
for
q
in
el
.
itervalues
()]),
set
([
str
])
)
def
assertComputerPUTSimulatorEmpty
(
self
):
self
.
assertEqual
(
''
,
open
(
self
.
computer_put_simulator
).
read
())
def
test
(
self
):
d
=
{
"partition"
:
[
{
"title"
:
"part0"
,
"public_ip"
:
"::0"
,
"private_ip"
:
"127.0.0.0"
,
"tap_interface"
:
"tap0"
}
],
"software"
:
[
{
"software_release"
:
"software_release"
,
"status"
:
"uninstalled"
,
"log"
:
"Installation log"
}
]
}
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]),
body
=
json
.
dumps
(
d
),
headers
=
{
'REMOTE_USER'
:
self
.
computer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
204
)
self
.
assertComputerPUTSimulator
([
{
'recmethod'
:
'Computer_updateFromJson'
,
'recargs'
:
({
'partition'
:
[{
'public_ip'
:
'::0'
,
'tap_interface'
:
'tap0'
,
'private_ip'
:
'127.0.0.0'
,
'title'
:
'part0'
}],
'software'
:
[{
'status'
:
'uninstalled'
,
'software_release'
:
'software_release'
,
'log'
:
'Installation log'
}]},),
'reckwargs'
:
{}}])
def
test_not_logged_in
(
self
):
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]))
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
401
)
self
.
assertTrue
(
self
.
response
.
getheader
(
'Location'
)
is
not
None
)
auth
=
self
.
response
.
getheader
(
'WWW-Authenticate'
)
self
.
assertTrue
(
auth
is
not
None
)
self
.
assertTrue
(
'Bearer realm="'
in
auth
)
self
.
assertComputerPUTSimulatorEmpty
()
def
test_no_json
(
self
):
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
computer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertEqual
({
'error'
:
"Data is not json object."
},
self
.
json_response
)
self
.
assertComputerPUTSimulatorEmpty
()
def
test_bad_json
(
self
):
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]),
body
=
'This is not JSON'
,
headers
=
{
'REMOTE_USER'
:
self
.
computer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertEqual
({
'error'
:
"Data is not json object."
},
self
.
json_response
)
self
.
assertComputerPUTSimulatorEmpty
()
def
test_empty_json
(
self
):
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]),
body
=
'{}'
,
headers
=
{
'REMOTE_USER'
:
self
.
computer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
204
)
self
.
assertComputerPUTSimulatorEmpty
()
def
test_future_compat
(
self
):
self
.
connection
.
request
(
method
=
'PUT'
,
url
=
'/'
.
join
([
self
.
api_path
,
'computer'
,
self
.
computer
.
getRelativeUrl
()]),
body
=
json
.
dumps
({
'ignore'
:
'me'
}),
headers
=
{
'REMOTE_USER'
:
self
.
computer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
204
)
self
.
assertComputerPUTSimulatorEmpty
()
def
test_software_release_status
(
self
):
raise
NotImplementedError
def
test_only_partition
(
self
):
raise
NotImplementedError
def
test_only_software
(
self
):
raise
NotImplementedError
def
test_partition_object_incorrect
(
self
):
raise
NotImplementedError
def
test_software_object_incorrect
(
self
):
raise
NotImplementedError
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
61eeec57
58
59
\ No newline at end of file
\ No newline at end of file
master/bt5/vifib_slapos_rest_api_v1_test/bt/template_path_list
View file @
61eeec57
computer_module/template_computer
hosting_subscription_module/template_hosting_subscription
hosting_subscription_module/template_hosting_subscription
software_instance_module/template_software_instance
software_instance_module/template_software_instance
\ No newline at end of file
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