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
Léo-Paul Géneau
slapos.core
Commits
9bd7b9f3
Commit
9bd7b9f3
authored
Sep 13, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Slap tests about raised exceptions by SLAP
parent
872a2559
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
slapos/tests/slap.py
slapos/tests/slap.py
+37
-15
No files found.
slapos/tests/slap.py
View file @
9bd7b9f3
...
...
@@ -198,16 +198,26 @@ class TestSlap(SlapMixin):
def
test_registerComputerPartition_unknown_computer_guid
(
self
):
"""
Asserts that calling slap.registerComputerPartition on unknown
computer raises
(not defined yet)
exception
computer raises
NotFoundError
exception
"""
raise
NotImplementedError
()
computer_guid
=
self
.
_getTestComputerId
()
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
)
partition_id
=
'PARTITION_01'
self
.
assertRaises
(
UndefinedYetException
,
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
(
404
,
{},
''
)
else
:
return
(
0
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
self
.
assertRaises
(
slapos
.
slap
.
NotFoundError
,
self
.
slap
.
registerComputerPartition
,
computer_guid
,
partition_id
)
class
TestComputer
(
SlapMixin
):
...
...
@@ -553,32 +563,44 @@ class TestSoftwareRelease(SlapMixin):
software_release
=
self
.
slap
.
registerSoftwareRelease
(
self
.
software_release_uri
)
method
=
getattr
(
software_release
,
state
)
self
.
assertRaises
(
UndefinedYetException
,
method
)
self
.
assertRaises
(
NameError
,
method
)
def
test_available_new_SoftwareRelease_raises
(
self
):
"""
Asserts that calling SoftwareRelease.available on new software release
raises
(not defined yet)
exception
raises
NameError
exception
"""
self
.
_test_new_software_release_state
(
'available'
)
def
test_building_new_SoftwareRelease_raises
(
self
):
"""
Asserts that calling SoftwareRelease.building on new software release
raises
(not defined yet)
exception
raises
NameError
exception
"""
self
.
_test_new_software_release_state
(
'building'
)
def
test_error_new_SoftwareRelease_works
(
self
):
"""
Asserts that calling SoftwareRelease.error on
new
software release works
Asserts that calling SoftwareRelease.error on software release works
"""
self
.
software_release_uri
=
'http://server/'
+
self
.
_getTestComputerId
()
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
)
software_release
=
self
.
slap
.
registerSoftwareRelease
(
self
.
software_release_uri
)
# XXX: Interface does not define return value
computer_guid
=
self
.
_getTestComputerId
()
software_release_uri
=
'http://server/'
+
self
.
_getTestComputerId
()
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
(
body
)
if
parsed_url
.
path
==
'softwareReleaseError'
and
\
parsed_qs
[
'computer_id'
][
0
]
==
computer_guid
and
\
parsed_qs
[
'url'
][
0
]
==
software_release_uri
and
\
parsed_qs
[
'error_log'
][
0
]
==
'some error'
:
return
(
200
,
{},
''
)
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
software_release
=
self
.
slap
.
registerSoftwareRelease
(
software_release_uri
)
software_release
.
_computer_guid
=
computer_guid
software_release
.
error
(
'some error'
)
class
TestOpenOrder
(
SlapMixin
):
...
...
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