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
Cédric Le Ninivin
slapos.core
Commits
b7f5c811
Commit
b7f5c811
authored
Sep 13, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add http callbacks to make more slap test pass
parent
a7b153b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
16 deletions
+54
-16
slapos/tests/slap.py
slapos/tests/slap.py
+54
-16
No files found.
slapos/tests/slap.py
View file @
b7f5c811
...
...
@@ -220,11 +220,11 @@ class TestComputer(SlapMixin):
Asserts that calling Computer.getComputerPartitionList without Computer
Partitions returns empty list
"""
self
.
computer_guid
=
self
.
_getTestComputerId
()
s
elf
.
slap
=
slapos
.
slap
.
slap
()
s
elf
.
s
lap
.
initializeConnection
(
self
.
server_url
)
self
.
computer
=
self
.
slap
.
registerComputer
(
self
.
computer_guid
)
self
.
assertEqual
(
self
.
computer
.
getComputerPartitionList
(),
[])
computer_guid
=
self
.
_getTestComputerId
()
s
lap
=
self
.
slap
slap
.
initializeConnection
(
self
.
server_url
)
computer
=
self
.
slap
.
registerComputer
(
computer_guid
)
self
.
assertEqual
(
computer
.
getComputerPartitionList
(),
[])
def
test_computer_getComputerPartitionList_only_partition
(
self
):
"""
...
...
@@ -396,7 +396,8 @@ class TestComputerPartition(SlapMixin):
self
.
assertTrue
(
isinstance
(
requested_partition
,
slapos
.
slap
.
ComputerPartition
))
# as request method does not raise, accessing data raises
self
.
assertRaises
(
slapos
.
slap
.
ResourceNotReady
,
requested_partition
.
getId
)
self
.
assertRaises
(
slapos
.
slap
.
ResourceNotReady
,
requested_partition
.
getId
)
def
test_request_fullfilled_work
(
self
):
partition_id
=
'PARTITION_01'
...
...
@@ -449,14 +450,28 @@ class TestComputerPartition(SlapMixin):
Helper method to automate assertions of failing states on new Computer
Partition
"""
self
.
computer_guid
=
self
.
_getTestComputerId
()
computer_guid
=
self
.
_getTestComputerId
()
partition_id
=
'PARTITION_01'
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
)
slap
=
self
.
slap
slap
.
initializeConnection
(
self
.
server_url
)
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'registerComputerPartition'
and
\
parsed_qs
[
'computer_reference'
][
0
]
==
computer_guid
and
\
parsed_qs
[
'computer_partition_reference'
][
0
]
==
partition_id
:
partition
=
slapos
.
slap
.
ComputerPartition
(
computer_guid
,
partition_id
)
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
partition
))
else
:
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
computer_partition
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_guid
,
partition_id
)
computer_guid
,
partition_id
)
method
=
getattr
(
computer_partition
,
state
)
self
.
assertRaises
(
UndefinedYetException
,
method
)
self
.
assertRaises
(
slapos
.
slap
.
NotFoundError
,
method
)
def
test_available_new_ComputerPartition_raises
(
self
):
"""
...
...
@@ -490,12 +505,35 @@ class TestComputerPartition(SlapMixin):
"""
Asserts that calling ComputerPartition.error on new partition works
"""
self
.
computer_guid
=
self
.
_getTestComputerId
()
computer_guid
=
self
.
_getTestComputerId
()
partition_id
=
'PARTITION_01'
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
)
computer_partition
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_guid
,
partition_id
)
slap
=
self
.
slap
slap
.
initializeConnection
(
self
.
server_url
)
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'registerComputerPartition'
and
\
parsed_qs
[
'computer_reference'
][
0
]
==
computer_guid
and
\
parsed_qs
[
'computer_partition_reference'
][
0
]
==
partition_id
:
partition
=
slapos
.
slap
.
ComputerPartition
(
computer_guid
,
partition_id
)
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
partition
))
elif
parsed_url
.
path
==
'softwareInstanceError'
:
parsed_qs_body
=
urlparse
.
parse_qs
(
body
)
# XXX: why do we have computer_id and not computer_reference?
# XXX: why do we have computer_partition_id and not
# computer_partition_reference?
if
parsed_qs_body
[
'computer_id'
][
0
]
==
computer_guid
and
\
parsed_qs_body
[
'computer_partition_id'
][
0
]
==
partition_id
and
\
parsed_qs_body
[
'error_log'
][
0
]
==
'some error'
:
return
(
200
,
{},
''
)
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
computer_partition
=
slap
.
registerComputerPartition
(
computer_guid
,
partition_id
)
# XXX: Interface does not define return value
computer_partition
.
error
(
'some error'
)
...
...
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