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
Xavier Thompson
slapos.core
Commits
78f01daf
Commit
78f01daf
authored
Jan 08, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_slap_tool: Add test to call API Twice
'since' should be unmutable.
parent
9e1ec652
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
16 deletions
+104
-16
master/bt5/slapos_slap_tool/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSSlapTool.xml
...eItem/portal_components/extension.erp5.SlapOSSlapTool.xml
+1
-0
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
...ateItem/portal_components/test.erp5.testSlapOSSlapTool.py
+87
-0
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.xml
...teItem/portal_components/test.erp5.testSlapOSSlapTool.xml
+16
-16
No files found.
master/bt5/slapos_slap_tool/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSSlapTool.xml
View file @
78f01daf
...
...
@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
...
...
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
View file @
78f01daf
...
...
@@ -7,6 +7,7 @@ from App.Common import rfc1123_date
import
os
import
tempfile
import
time
# blurb to make nice XML comparisions
import
xml.dom.ext.reader.Sax
...
...
@@ -1574,6 +1575,92 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
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_softwareInstanceError_twice
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
error_log
=
'The error'
response
=
self
.
portal_slap
.
softwareInstanceError
(
self
.
computer_id
,
partition_id
,
error_log
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
since
=
created_at
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<string>created_at</string>
<string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string>
<string>#error while instanciating: The error</string>
<string>user</string>
<string>%(instance_guid)s</string>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
since
=
since
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
self
.
unpinDateTime
()
time
.
sleep
(
1
)
self
.
pinDateTime
(
DateTime
())
response
=
self
.
portal_slap
.
softwareInstanceError
(
self
.
computer_id
,
partition_id
,
error_log
)
self
.
assertEqual
(
'None'
,
response
)
ncreated_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
self
.
assertNotEquals
(
created_at
,
ncreated_at
)
self
.
assertNotEquals
(
since
,
ncreated_at
)
self
.
assertEquals
(
since
,
created_at
)
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<string>created_at</string>
<string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string>
<string>#error while instanciating: The error</string>
<string>user</string>
<string>%(instance_guid)s</string>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
ncreated_at
,
since
=
since
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
assertInstanceBangSimulator
(
self
,
args
,
kwargs
):
stored
=
eval
(
open
(
self
.
instance_bang_simulator
).
read
())
# do the same translation magic as in workflow
...
...
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.xml
View file @
78f01daf
...
...
@@ -46,22 +46,22 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 2
7
, 10: Use of eval (eval-used)
</string>
<string>
W:5
40
, 13: Use of eval (eval-used)
</string>
<string>
W:59
5
, 13: Use of eval (eval-used)
</string>
<string>
W:8
36
, 13: Use of eval (eval-used)
</string>
<string>
W:14
61
, 13: Use of eval (eval-used)
</string>
<string>
W:1
578
, 13: Use of eval (eval-used)
</string>
<string>
W:1
636
, 13: Use of eval (eval-used)
</string>
<string>
W:1
676
, 13: Use of eval (eval-used)
</string>
<string>
W:2
239
, 13: Use of eval (eval-used)
</string>
<string>
W:26
40
, 13: Use of eval (eval-used)
</string>
<string>
W:2
698
, 13: Use of eval (eval-used)
</string>
<string>
W:27
25
, 13: Use of eval (eval-used)
</string>
<string>
W:2
882
, 13: Use of eval (eval-used)
</string>
<string>
W:29
10
, 13: Use of eval (eval-used)
</string>
<string>
W:
2959
, 13: Use of eval (eval-used)
</string>
<string>
W:30
06
, 13: Use of eval (eval-used)
</string>
<string>
W: 2
8
, 10: Use of eval (eval-used)
</string>
<string>
W:5
37
, 13: Use of eval (eval-used)
</string>
<string>
W:59
2
, 13: Use of eval (eval-used)
</string>
<string>
W:8
29
, 13: Use of eval (eval-used)
</string>
<string>
W:14
46
, 13: Use of eval (eval-used)
</string>
<string>
W:1
649
, 13: Use of eval (eval-used)
</string>
<string>
W:1
707
, 13: Use of eval (eval-used)
</string>
<string>
W:1
747
, 13: Use of eval (eval-used)
</string>
<string>
W:2
306
, 13: Use of eval (eval-used)
</string>
<string>
W:26
99
, 13: Use of eval (eval-used)
</string>
<string>
W:2
757
, 13: Use of eval (eval-used)
</string>
<string>
W:27
84
, 13: Use of eval (eval-used)
</string>
<string>
W:2
941
, 13: Use of eval (eval-used)
</string>
<string>
W:29
69
, 13: Use of eval (eval-used)
</string>
<string>
W:
3018
, 13: Use of eval (eval-used)
</string>
<string>
W:30
65
, 13: Use of eval (eval-used)
</string>
</tuple>
</value>
</item>
...
...
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