Commit bd4001bb authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: fix SupportRequest_updateMonitoringHostingSubscriptionState and add test.

parent cb2515a5
Pipeline #2754 skipped
......@@ -4,7 +4,7 @@ import json
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject()
document = context.getSourceProjectValue()
document = context.getAggregateValue()
if document is None:
return
......@@ -13,7 +13,7 @@ has_error = False
# Check if at least one software Instance is Allocated
for instance in document.getSpecialiseRelatedValueList(
portal_type=["Software Instance", "Slave Instance"]):
portal_type=["Software Instance", "Slave Instance"]):
if instance.getSlapState() not in ["start_requested", "stop_requested"]:
continue
......@@ -25,7 +25,7 @@ for instance in document.getSpecialiseRelatedValueList(
else:
has_error = True
break
if not has_error:
person = context.getDestinationDecision(portal_type="Person")
if not person:
......@@ -37,8 +37,7 @@ if not has_error:
return
# Send Notification message
message = """ Suspending this ticket as the problem is not present anymore.
"""
message = """ Suspending this ticket as the problem is not present anymore. """
notification_reference = "slapos-crm-support-request-suspend-hs-notification"
notification_message = portal.portal_notifications.getDocumentValue(
......
......@@ -8,7 +8,6 @@ from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
import json
from unittest import skip
def simulate(script_id, params_string, code_string):
def upperWrap(f):
......@@ -3634,7 +3633,6 @@ class TestSupportRequestUpdateMonitoringState(testSlapOSMixin):
support_request.SupportRequest_updateMonitoringComputerState())
self.assertEquals(support_request.getSimulationState(), "suspended")
@skip("Missing to finish")
@simulate('SupportRequest_trySendNotificationMessage',
"message_title, message, source_relative_url",
'return "Visited by SupportRequest_trySendNotificationMessage '\
......@@ -3652,8 +3650,18 @@ class TestSupportRequestUpdateMonitoringState(testSlapOSMixin):
support_request.SupportRequest_updateMonitoringHostingSubscriptionState())
support_request.setAggregateValue(self._makeHostingSubscription())
self.assertEquals(None,
support_request.SupportRequest_updateMonitoringHostingSubscriptionState())
support_request.setDestinationDecisionValue(self._makePerson())
raise NotImplementedError("Not implemented yet")
self.assertEquals("Visited by SupportRequest_trySendNotificationMessage Suspending this ticket as the problem is not present anymore Suspending this ticket as the problem is not present anymore. %s" % \
support_request.getDestinationDecision(),
support_request.SupportRequest_updateMonitoringHostingSubscriptionState())
self.assertEquals("suspended",
support_request.getSimulationState())
@simulate('SupportRequest_trySendNotificationMessage',
"message_title, message, source_relative_url",
......@@ -3686,3 +3694,4 @@ class TestSupportRequestUpdateMonitoringState(testSlapOSMixin):
self.assertEquals("invalidated",
support_request.getSimulationState())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment