Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
343aef27
Commit
343aef27
authored
Oct 27, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testERP5TestNode: simplify reset software tests by using mock
parent
56ac53ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
29 deletions
+23
-29
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+23
-29
No files found.
erp5/tests/testERP5TestNode.py
View file @
343aef27
...
@@ -1162,44 +1162,38 @@ shared = true
...
@@ -1162,44 +1162,38 @@ shared = true
set
([
'buildoutA'
,
'tmpC'
,
'tmp-cannot-delete'
]).
intersection
(
set
([
'buildoutA'
,
'tmpC'
,
'tmp-cannot-delete'
]).
intersection
(
set
(
os
.
listdir
(
temp_directory
))))
set
(
os
.
listdir
(
temp_directory
))))
def
test_
18_resetSoftwareAfterManyBuildFailures
(
self
,
my_test_type
=
'UnitTest'
):
def
test_
resetSoftwareAfterManyBuildFailures
(
self
):
"""
"""
Check that after several building failures that the software is resetted
Check that after several building failures that the software is resetted
"""
"""
initial_initializeSlapOSControler
=
\
SlapOSControler
.
initializeSlapOSControler
initial_runSoftwareRelease
=
SlapOSControler
.
runSoftwareRelease
test_node
=
self
.
getTestNode
()
test_node
=
self
.
getTestNode
()
runner
=
test_type_registry
[
my_test_type
](
test_node
)
runner
=
test_type_registry
[
'UnitTest'
](
test_node
)
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
init_call_kw_list
=
[]
def
initializeSlapOSControler
(
self
,
**
kw
):
init_call_kw_list
.
append
(
kw
)
def
runSoftwareRelease
(
self
,
*
args
,
**
kw
):
return
{
"status_code"
:
1
}
SlapOSControler
.
initializeSlapOSControler
=
initializeSlapOSControler
SlapOSControler
.
runSoftwareRelease
=
runSoftwareRelease
def
callPrepareSlapOS
():
runner
.
_prepareSlapOS
(
self
.
working_directory
,
node_test_suite
,
create_partition
=
0
)
def
callRaisingPrepareSlapos
():
def
callRaisingPrepareSlapos
():
self
.
assertRaises
(
SubprocessError
,
callPrepareSlapOS
)
with
self
.
assertRaises
(
SubprocessError
):
runner
.
_prepareSlapOS
(
self
.
working_directory
,
node_test_suite
,
create_partition
=
0
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
0
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
0
)
with
mock
.
patch
.
object
(
SlapOSControler
,
'initializeSlapOSControler'
)
as
initializeSlapOSControler
,
\
mock
.
patch
.
object
(
SlapOSControler
,
'runSoftwareRelease'
,
return_value
=
{
"status_code"
:
1
}):
for
_
in
range
(
11
):
for
_
in
range
(
11
):
callRaisingPrepareSlapos
()
callRaisingPrepareSlapos
()
self
.
assertEqual
(
len
(
init_call_kw_list
),
11
)
self
.
assertEqual
(
init_call_kw_list
[
-
1
][
'reset_software'
],
False
)
self
.
assertEqual
(
len
(
initializeSlapOSControler
.
mock_calls
),
11
)
self
.
assertEqual
(
initializeSlapOSControler
.
mock_calls
[
-
1
][
2
][
'reset_software'
],
False
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
11
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
11
)
callRaisingPrepareSlapos
()
callRaisingPrepareSlapos
()
self
.
assertEqual
(
init_call_kw_list
[
-
1
][
'reset_software'
],
True
)
self
.
assertEqual
(
initializeSlapOSControler
.
mock_calls
[
-
1
][
2
][
'reset_software'
],
True
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
1
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
1
)
callRaisingPrepareSlapos
()
callRaisingPrepareSlapos
()
self
.
assertEqual
(
init_call_kw_list
[
-
1
][
'reset_software'
],
False
)
self
.
assertEqual
(
initializeSlapOSControler
.
mock_calls
[
-
1
][
2
][
'reset_software'
],
False
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
2
)
self
.
assertEqual
(
node_test_suite
.
retry_software_count
,
2
)
SlapOSControler
.
initializeSlapOSControler
=
\
initial_initializeSlapOSControler
SlapOSControler
.
runSoftwareRelease
=
initial_runSoftwareRelease
def
test_scalability_04_constructProfile
(
self
,
my_test_type
=
'ScalabilityTest'
):
def
test_scalability_04_constructProfile
(
self
,
my_test_type
=
'ScalabilityTest'
):
self
.
test_04_constructProfile
(
my_test_type
)
self
.
test_04_constructProfile
(
my_test_type
)
...
...
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