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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
a5190f56
Commit
a5190f56
authored
Feb 15, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: test: use PinnedDateTime context
parent
d249a665
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
75 deletions
+21
-75
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+15
-54
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+6
-21
No files found.
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
a5190f56
...
...
@@ -21,7 +21,7 @@
#
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
\
SlapOSTestCaseMixin
,
SlapOSTestCaseMixinWithAbort
,
simulate
,
TemporaryAlarmScript
SlapOSTestCaseMixin
,
SlapOSTestCaseMixinWithAbort
,
simulate
,
TemporaryAlarmScript
,
PinnedDateTime
from
DateTime
import
DateTime
import
difflib
import
transaction
...
...
@@ -1280,12 +1280,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
'*args, **kwargs'
,
'return 0'
)
def
test_ComputeNode_checkState_script_oldAccessStatus
(
self
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
try
:
d
=
DateTime
()
-
1.1
self
.
pinDateTime
(
d
)
d
=
DateTime
()
-
1.1
with
PinnedDateTime
(
self
,
d
):
compute_node
.
setAccessStatus
(
""
)
finally
:
self
.
unpinDateTime
()
compute_node_support_request
=
compute_node
.
ComputeNode_checkState
()
self
.
assertNotEqual
(
compute_node_support_request
,
None
)
...
...
@@ -1334,11 +1331,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
def
test_ComputeNode_checkState_script_notify
(
self
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
compute_node
.
setAccessStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
portal
.
REQUEST
[
'test_ComputeNode_checkState_notify'
]
=
\
self
.
_makeNotificationMessage
(
compute_node
.
getReference
())
...
...
@@ -1423,11 +1417,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
# Computer is getting access
compute_node
.
setAccessStatus
(
""
)
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
self
.
start_requested_software_instance
.
setAccessStatus
(
""
)
finally
:
self
.
unpinDateTime
()
compute_node
.
ComputeNode_checkState
()
self
.
tic
()
...
...
@@ -1471,12 +1462,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
# Computer is getting access
compute_node
.
setAccessStatus
(
""
)
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
self
.
start_requested_software_instance
.
setAccessStatus
(
""
)
self
.
start_requested_software_installation
.
setAccessStatus
(
""
)
finally
:
self
.
unpinDateTime
()
compute_node
.
ComputeNode_checkState
()
self
.
tic
()
...
...
@@ -1558,13 +1546,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
'return context.restrictedTraverse('
\
'context.REQUEST["test_ComputeNode_checkSoftwareInstallationState_notify"])'
)
def
test_ComputeNode_checkSoftwareInstallationState_script_notifyNoInformation
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
compute_node
=
self
.
compute_node
finally
:
self
.
unpinDateTime
()
self
.
tic
()
self
.
portal
.
REQUEST
[
'test_ComputeNode_checkSoftwareInstallationState_notify'
]
=
\
...
...
@@ -1608,13 +1593,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
'return context.restrictedTraverse('
\
'context.REQUEST["test_ComputeNode_checkSoftwareInstallationState_notify"])'
)
def
test_ComputeNode_checkSoftwareInstallationState_script_notifySlow
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
compute_node
=
self
.
compute_node
finally
:
self
.
unpinDateTime
()
self
.
start_requested_software_installation
.
setBuildingStatus
(
"building"
)
self
.
tic
()
...
...
@@ -1685,13 +1667,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
'return context.restrictedTraverse('
\
'context.REQUEST["test_ComputeNode_checkSoftwareInstallationState_notify"])'
)
def
test_ComputeNode_checkSoftwareInstallationState_script_notifyError
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
compute_node
=
self
.
compute_node
finally
:
self
.
unpinDateTime
()
self
.
start_requested_software_installation
.
setErrorStatus
(
""
)
self
.
tic
()
...
...
@@ -1734,13 +1713,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
'return context.restrictedTraverse('
\
'context.REQUEST["test_ComputeNode_checkSoftwareInstallationState_notify"])'
)
def
test_ComputeNode_checkSoftwareInstallationState_script_oldBuild
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
compute_node
=
self
.
compute_node
finally
:
self
.
unpinDateTime
()
self
.
start_requested_software_installation
.
setAccessStatus
(
""
)
self
.
tic
()
...
...
@@ -1819,16 +1795,13 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
'return context.restrictedTraverse('
\
'context.REQUEST["test_InstanceTree_checkSoftwareInstanceState_notify"])'
)
def
test_InstanceTree_checkSoftwareInstanceState_script_notifyError
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
software_instance
=
self
.
start_requested_software_instance
instance_tree
=
software_instance
.
getSpecialiseValue
()
software_instance
.
setErrorStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
portal
.
REQUEST
[
'test_InstanceTree_checkSoftwareInstanceState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
...
...
@@ -1864,15 +1837,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
def
test_InstanceTree_checkSoftwareInstanceState_script_notifyErrorTolerance
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
software_instance
=
self
.
start_requested_software_instance
instance_tree
=
software_instance
.
getSpecialiseValue
()
finally
:
self
.
unpinDateTime
()
software_instance
.
setErrorStatus
(
""
)
...
...
@@ -1897,15 +1867,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
'return context.restrictedTraverse('
\
'context.REQUEST["test_InstanceTree_checkSoftwareInstanceState_notify"])'
)
def
test_InstanceTree_checkSoftwareInstanceState_script_notifyNotAllocated
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1.1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1.1
):
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
software_instance
=
self
.
start_requested_software_instance
instance_tree
=
software_instance
.
getSpecialiseValue
()
finally
:
self
.
unpinDateTime
()
self
.
portal
.
REQUEST
[
'test_InstanceTree_checkSoftwareInstanceState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
...
...
@@ -1942,16 +1909,13 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
def
test_InstanceTree_checkSoftwareInstanceState_script_tooEarly
(
self
):
try
:
self
.
pinDateTime
(
DateTime
())
with
PinnedDateTime
(
self
,
DateTime
()):
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
software_instance
=
self
.
start_requested_software_instance
instance_tree
=
software_instance
.
getSpecialiseValue
()
software_instance
.
setErrorStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
portal
.
REQUEST
[
'test_InstanceTree_checkSoftwareInstanceState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
...
...
@@ -1969,16 +1933,13 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 1'
)
def
test_InstanceTree_checkSoftwareInstanceState_script_closed
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
1
)
with
PinnedDateTime
(
self
,
DateTime
()
-
1
):
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
_makeComplexComputeNode
(
self
.
addProject
())
software_instance
=
self
.
start_requested_software_instance
instance_tree
=
software_instance
.
getSpecialiseValue
()
software_instance
.
setErrorStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
portal
.
REQUEST
[
'test_InstanceTree_checkSoftwareInstanceState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
a5190f56
...
...
@@ -23,7 +23,7 @@
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
\
SlapOSTestCaseMixin
,
SlapOSTestCaseMixinWithAbort
,
TemporaryAlarmScript
SlapOSTestCaseMixin
,
SlapOSTestCaseMixinWithAbort
,
TemporaryAlarmScript
,
PinnedDateTime
from
DateTime
import
DateTime
from
App.Common
import
rfc1123_date
...
...
@@ -169,22 +169,16 @@ class TestComputeNode_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
self
.
assertTrue
(
has_contacted
)
def
test_ComputeNode_hasContactedRecently_no_data
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
32
)
with
PinnedDateTime
(
self
,
DateTime
()
-
32
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
finally
:
self
.
unpinDateTime
()
self
.
tic
()
has_contacted
=
compute_node
.
ComputeNode_hasContactedRecently
()
self
.
assertFalse
(
has_contacted
)
def
test_ComputeNode_hasContactedRecently_memcached
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
32
)
with
PinnedDateTime
(
self
,
DateTime
()
-
32
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
finally
:
self
.
unpinDateTime
()
compute_node
.
setAccessStatus
(
""
)
self
.
tic
()
...
...
@@ -193,12 +187,9 @@ class TestComputeNode_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
self
.
assertTrue
(
has_contacted
)
def
test_ComputeNode_hasContactedRecently_memcached_oudated_no_spl
(
self
):
try
:
self
.
pinDateTime
(
DateTime
()
-
32
)
with
PinnedDateTime
(
self
,
DateTime
()
-
32
):
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
addProject
())
compute_node
.
setAccessStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
tic
()
...
...
@@ -309,11 +300,8 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
_
,
partition
=
self
.
_makeComputeNode
(
self
.
addProject
())
error_date
=
DateTime
()
try
:
self
.
pinDateTime
(
error_date
)
with
PinnedDateTime
(
self
,
error_date
):
instance
.
setErrorStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
assertEqual
(
instance
.
SoftwareInstance_hasReportedError
(),
None
)
...
...
@@ -330,11 +318,8 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self
.
assertEqual
(
installation
.
SoftwareInstallation_hasReportedError
(),
None
)
error_date
=
DateTime
()
try
:
self
.
pinDateTime
(
error_date
)
with
PinnedDateTime
(
self
,
error_date
):
installation
.
setErrorStatus
(
""
)
finally
:
self
.
unpinDateTime
()
self
.
assertEqual
(
rfc1123_date
(
installation
.
SoftwareInstallation_hasReportedError
()),
...
...
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