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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
c9598767
Commit
c9598767
authored
Sep 05, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: add/fix test for create alarm to close personal computer
parent
11ba14cf
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
35 deletions
+164
-35
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
...ng/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
+5
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.py
...ns/slapos_crm_monitoring/Computer_hasContactedRecently.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.xml
...s/slapos_crm_monitoring/Computer_hasContactedRecently.xml
+1
-1
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+33
-18
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+124
-15
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
View file @
c9598767
from
DateTime
import
DateTime
from
Products.ERP5Type.DateUtils
import
addToDate
from
Products.ZSQLCatalog.SQLCatalog
import
Query
portal
=
context
.
getPortalObject
()
category_personal
=
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/personal"
,
None
)
...
...
@@ -6,6 +10,7 @@ if category_personal is not None:
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Computer'
,
validation_state
=
'validated'
,
creation_date
=
Query
(
range
=
"max"
,
creation_date
=
addToDate
(
DateTime
(),
{
'day'
:
-
30
})),
default_allocation_scope_uid
=
category_personal
.
getUid
(),
method_id
=
'Computer_checkAndUpdatePersonalAllocationScope'
,
activate_kw
=
{
'tag'
:
tag
})
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.py
View file @
c9598767
import
json
portal
=
context
.
getPortalObject
()
computer
=
context
maximum_days
=
31
now_date
=
DateTime
()
if
(
now_date
-
computer
.
getCreationDate
())
<
maximum_days
:
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.xml
View file @
c9598767
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
maximum_days=30
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
c9598767
...
...
@@ -969,44 +969,58 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
def
test_alarm_allowed_allocation_scope_OpenPersonal_old_computer
(
self
):
self
.
_makeComputer
()
def
getCreationDate
(
self
):
return
DateTime
()
-
31
self
.
computer
.
edit
(
allocation_scope
=
'open/personal'
)
def
getModificationDate
(
self
):
return
DateTime
()
-
50
from
Products.ERP5Type.Base
import
Base
self
.
_simulateComputer_checkAndUpdatePersonalAllocationScope
()
original_get_
modification
=
Base
.
getModific
ationDate
Base
.
get
ModificationDate
=
getModific
ationDate
original_get_
creation
=
Base
.
getCre
ationDate
Base
.
get
CreationDate
=
getCre
ationDate
try
:
self
.
portal
.
portal_alarms
.
slapos_crm_check_update_personal_allocation_scope
.
activeSense
()
self
.
tic
()
finally
:
Base
.
get
ModificationDate
=
original_get_modific
ation
Base
.
get
CreationDate
=
original_get_cre
ation
self
.
_dropComputer_checkAndUpdatePersonalAllocationScope
()
self
.
assertEqual
(
'Visited by Computer_checkAndUpdatePersonalAllocationScope'
,
self
.
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_allowed_allocation_scope_OpenPersonal
WithSoftwareInstallation
(
self
):
def
test_alarm_allowed_allocation_scope_OpenPersonal
_recent_computer
(
self
):
self
.
_makeComputer
()
def
getCreationDate
(
self
):
return
DateTime
()
-
28
self
.
computer
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
_makeSoftwareInstallation
()
def
getModificationDate
(
self
):
return
DateTime
()
-
50
from
Products.ERP5Type.Base
import
Base
self
.
_simulateComputer_checkAndUpdatePersonalAllocationScope
()
original_get_creation
=
Base
.
getCreationDate
Base
.
getCreationDate
=
getCreationDate
try
:
self
.
portal
.
portal_alarms
.
slapos_crm_check_update_personal_allocation_scope
.
activeSense
()
self
.
tic
()
finally
:
Base
.
getCreationDate
=
original_get_creation
self
.
_dropComputer_checkAndUpdatePersonalAllocationScope
()
self
.
assertNotEqual
(
'Visited by Computer_checkAndUpdatePersonalAllocationScope'
,
self
.
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_allowed_allocation_scope_OpenPersonal_already_closed
(
self
):
self
.
_makeComputer
()
self
.
computer
.
edit
(
allocation_scope
=
'open/oudated'
)
self
.
_simulateComputer_checkAndUpdatePersonalAllocationScope
()
original_get_modification
=
Base
.
getModificationDate
Base
.
getModificationDate
=
getModificationDate
try
:
self
.
portal
.
portal_alarms
.
slapos_crm_check_update_personal_allocation_scope
.
activeSense
()
self
.
tic
()
finally
:
Base
.
getModificationDate
=
original_get_modification
self
.
_dropComputer_checkAndUpdatePersonalAllocationScope
()
self
.
assertNotEqual
(
'Visited by Computer_checkAndUpdatePersonalAllocationScope'
,
...
...
@@ -1093,5 +1107,6 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
self
.
assertNotEqual
(
'Visited by HostingSubscription_checkSofwareInstanceState'
,
host_sub
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
c9598767
This diff is collapsed.
Click to expand it.
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