Commit 7d663881 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Fix Tests to follow up recent changes

parent 72a3ddb3
from DateTime import DateTime from DateTime import DateTime
import json
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject() portal = context.getPortalObject()
document = context.getAggregateValue() document = context.getAggregateValue()
...@@ -10,6 +7,7 @@ if document is None: ...@@ -10,6 +7,7 @@ if document is None:
return return
has_error = False has_error = False
software_instance = None
# Check if at least one software Instance is Allocated # Check if at least one software Instance is Allocated
for instance in document.getSpecialiseRelatedValueList( for instance in document.getSpecialiseRelatedValueList(
...@@ -20,6 +18,7 @@ for instance in document.getSpecialiseRelatedValueList( ...@@ -20,6 +18,7 @@ for instance in document.getSpecialiseRelatedValueList(
if instance.getAggregateValue() is not None: if instance.getAggregateValue() is not None:
if instance.getPortalType() == "Software Instance" and \ if instance.getPortalType() == "Software Instance" and \
instance.SoftwareInstance_hasReportedError(): instance.SoftwareInstance_hasReportedError():
software_instance = instance
has_error = True has_error = True
break break
else: else:
...@@ -29,17 +28,18 @@ for instance in document.getSpecialiseRelatedValueList( ...@@ -29,17 +28,18 @@ for instance in document.getSpecialiseRelatedValueList(
if not has_error: if not has_error:
person = context.getDestinationDecision(portal_type="Person") person = context.getDestinationDecision(portal_type="Person")
if not person: if not person:
return return
message = instance.SoftwareInstance_hasReportedError(include_message=True) if software_instance is not None:
if message in ["Not possible to find the last message", "#access instance available"]: message = software_instance.SoftwareInstance_hasReportedError(include_message=True)
# Do not change state in case of transitory states. if message in ["Not possible to find the last message", "#access instance available"]:
return message # Do not change state in case of transitory states.
return
if context.getSimulationState() == "validated": if context.getSimulationState() == "validated":
context.suspend() context.suspend()
else: else:
return return
# Send Notification message # 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. """
...@@ -53,6 +53,6 @@ if not has_error: ...@@ -53,6 +53,6 @@ if not has_error:
message = notification_message.asText( message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':mapping_dict}) substitution_method_parameter_dict={'mapping_dict':mapping_dict})
return context.SupportRequest_trySendNotificationMessage( return context.SupportRequest_trySendNotificationMessage(
"Suspending this ticket as the problem is not present anymore", message, person) "Suspending this ticket as the problem is not present anymore", message, person)
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