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
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
96cb590f
Commit
96cb590f
authored
Sep 12, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement http callback for each TestSlap case
parent
083c3a00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
slapos/tests/slap.py
slapos/tests/slap.py
+21
-7
No files found.
slapos/tests/slap.py
View file @
96cb590f
...
@@ -46,6 +46,8 @@ class SlapMixin(unittest.TestCase):
...
@@ -46,6 +46,8 @@ class SlapMixin(unittest.TestCase):
else
:
else
:
self
.
server_url
=
self
.
_server_url
self
.
server_url
=
self
.
_server_url
print
'Testing against SLAP server %r'
%
self
.
server_url
print
'Testing against SLAP server %r'
%
self
.
server_url
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
partition_id
=
'PARTITION_01'
def
tearDown
(
self
):
def
tearDown
(
self
):
if
self
.
_server_url
is
None
:
if
self
.
_server_url
is
None
:
...
@@ -162,14 +164,25 @@ class TestSlap(SlapMixin):
...
@@ -162,14 +164,25 @@ class TestSlap(SlapMixin):
Asserts that calling slap.registerComputerPartition on known computer
Asserts that calling slap.registerComputerPartition on known computer
returns ComputerPartition object
returns ComputerPartition object
"""
"""
self
.
computer_guid
=
self
.
_getTestComputerId
()
computer_guid
=
self
.
_getTestComputerId
()
self
.
slap
=
slapos
.
slap
.
slap
()
partition_id
=
self
.
partition_id
self
.
slap
.
initializeConnection
(
self
.
server_url
)
self
.
slap
.
initializeConnection
(
self
.
server_url
)
self
.
partition_id
=
'PARTITION_01'
self
.
slap
.
registerComputer
(
computer_guid
)
self
.
slap
.
registerComputer
(
self
.
computer_guid
)
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
partition
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_guid
,
partition
=
self
.
slap
.
registerComputerPartition
(
computer_guid
,
partition_id
)
self
.
partition_id
)
self
.
assertTrue
(
isinstance
(
partition
,
slapos
.
slap
.
ComputerPartition
))
self
.
assertTrue
(
isinstance
(
partition
,
slapos
.
slap
.
ComputerPartition
))
def
test_registerComputerPartition_existing_partition_id_known_computer_guid
(
self
):
def
test_registerComputerPartition_existing_partition_id_known_computer_guid
(
self
):
...
@@ -178,7 +191,7 @@ class TestSlap(SlapMixin):
...
@@ -178,7 +191,7 @@ class TestSlap(SlapMixin):
returns ComputerPartition object
returns ComputerPartition object
"""
"""
self
.
test_registerComputerPartition_new_partition_id_known_computer_guid
()
self
.
test_registerComputerPartition_new_partition_id_known_computer_guid
()
partition
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_guid
,
partition
=
self
.
slap
.
registerComputerPartition
(
self
.
_getTestComputerId
()
,
self
.
partition_id
)
self
.
partition_id
)
self
.
assertTrue
(
isinstance
(
partition
,
slapos
.
slap
.
ComputerPartition
))
self
.
assertTrue
(
isinstance
(
partition
,
slapos
.
slap
.
ComputerPartition
))
...
@@ -187,6 +200,7 @@ class TestSlap(SlapMixin):
...
@@ -187,6 +200,7 @@ class TestSlap(SlapMixin):
Asserts that calling slap.registerComputerPartition on unknown
Asserts that calling slap.registerComputerPartition on unknown
computer raises (not defined yet) exception
computer raises (not defined yet) exception
"""
"""
raise
NotImplementedError
()
computer_guid
=
self
.
_getTestComputerId
()
computer_guid
=
self
.
_getTestComputerId
()
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
)
self
.
slap
.
initializeConnection
(
self
.
server_url
)
...
...
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