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
Thomas Gambier
slapos.core
Commits
4691a18b
Commit
4691a18b
authored
Sep 05, 2014
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for getComputerConnectionParameterList
parent
995bea7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
5 deletions
+170
-5
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+169
-4
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
4691a18b
...
@@ -1917,6 +1917,171 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
...
@@ -1917,6 +1917,171 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getComputerConnectionParameterList
(
self
):
self
.
_makeComplexComputer
()
software_instance
=
self
.
start_requested_software_instance
hosting_subscription
=
software_instance
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription
.
setAggregateValue
(
self
.
computer
)
connection_xml
=
"""<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance
.
updateConnection
(
connection_xml
=
connection_xml
)
self
.
assertEquals
(
software_instance
.
getConnectionXml
(),
connection_xml
)
self
.
tic
()
connection_response
=
self
.
portal_slap
.
getComputerConnectionParameterList
(
self
.
computer
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
connection_response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
</list>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getComputerConnectionParameterList_two_hostingSubscriptions
(
self
):
self
.
_makeComplexComputer
()
software_instance
=
self
.
start_requested_software_instance
hosting_subscription
=
software_instance
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription
.
setAggregateValue
(
self
.
computer
)
# Stop_requested HostingSubsctiption
software_instance2
=
self
.
stop_requested_software_instance
hosting_subscription2
=
software_instance2
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription2
.
setAggregateValue
(
self
.
computer
)
connection_xml
=
"""<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance
.
updateConnection
(
connection_xml
=
connection_xml
)
self
.
assertEquals
(
software_instance
.
getConnectionXml
(),
connection_xml
)
software_instance2
.
updateConnection
(
connection_xml
=
connection_xml
)
self
.
assertEquals
(
software_instance2
.
getConnectionXml
(),
connection_xml
)
self
.
tic
()
connection_response
=
self
.
portal_slap
.
getComputerConnectionParameterList
(
self
.
computer
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
connection_response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
<dictionary id='i4'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
</list>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getComputerConnectionParameterList_no_parameters
(
self
):
self
.
_makeComplexComputer
()
software_instance
=
self
.
start_requested_software_instance
hosting_subscription
=
software_instance
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription
.
setAggregateValue
(
self
.
computer
)
self
.
tic
()
connection_response
=
self
.
portal_slap
.
getComputerConnectionParameterList
(
self
.
computer
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
connection_response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'/>
</list>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getComputerConnectionParameterList_invalid_hs
(
self
):
self
.
_makeComplexComputer
()
software_instance
=
self
.
start_requested_software_instance
hosting_subscription
=
software_instance
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription
.
setAggregateValue
(
self
.
computer
)
software_instance
.
invalidate
()
# Destroy_requested HostingSubsctiption
software_instance2
=
self
.
destroy_requested_software_instance
hosting_subscription2
=
software_instance2
.
getSpecialiseValue
(
software_type
=
"Hosting Subscription"
)
hosting_subscription2
.
setAggregateValue
(
self
.
computer
)
self
.
assertEqual
(
hosting_subscription2
.
getSlapState
(),
'destroy_requested'
)
connection_xml
=
"""<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance
.
updateConnection
(
connection_xml
=
connection_xml
)
software_instance2
.
updateConnection
(
connection_xml
=
connection_xml
)
self
.
tic
()
connection_response
=
self
.
portal_slap
.
getComputerConnectionParameterList
(
self
.
computer
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
connection_response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'/>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
class
TestSlapOSSlapToolPersonAccess
(
TestSlapOSSlapToolMixin
):
class
TestSlapOSSlapToolPersonAccess
(
TestSlapOSSlapToolMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
password
=
self
.
generateNewId
()
password
=
self
.
generateNewId
()
...
...
master/bt5/slapos_slap_tool/bt/revision
View file @
4691a18b
36
37
\ No newline at end of file
\ 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