Commit e81734a0 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Drop *_hasReportedError

parent 22aeb137
from DateTime import DateTime
if context.getAggregateValue(portal_type="Compute Partition") is not None:
d = context.getAccessStatus()
# Ignore if data isn't present.
if d.get("no_data", None) == 1:
if include_message:
return "Not possible to connect"
return
result = d['text']
last_contact = DateTime(d.get('created_at'))
since = DateTime(d.get('since'))
if result.startswith('#error '):
if ((DateTime()-since)*24*60) > tolerance:
if include_created_at and not include_since:
return result, last_contact
elif include_created_at and include_since:
return result, last_contact, since
return result
if include_message and include_created_at and not include_since:
return result, last_contact
elif include_message and include_created_at and include_since:
return result, last_contact, since
elif include_message and not include_created_at:
return result
return None
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>include_message=False, include_created_at=False, include_since=False, tolerance=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_hasReportedError</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -23,12 +23,11 @@ ...@@ -23,12 +23,11 @@
import transaction import transaction
from erp5.component.test.SlapOSTestCaseMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, TemporaryAlarmScript, PinnedDateTime SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, TemporaryAlarmScript
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
import os import os
from DateTime import DateTime from DateTime import DateTime
from App.Common import rfc1123_date
from zExceptions import Unauthorized from zExceptions import Unauthorized
...@@ -231,47 +230,6 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin): ...@@ -231,47 +230,6 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
# it dont close another project # it dont close another project
self.assertFalse(self.other_project.Project_isSupportRequestCreationClosed()) self.assertFalse(self.other_project.Project_isSupportRequestCreationClosed())
class TestSlapOSHasError(SlapOSTestCaseMixin):
def test_SoftwareInstance_hasReportedError(self):
instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
reference=self.generateNewId()
)
_, partition = self._makeComputeNode(self.addProject())
error_date = DateTime() - 0.1
with PinnedDateTime(self, error_date):
instance.setErrorStatus("")
self.assertEqual(instance.SoftwareInstance_hasReportedError(), None)
instance.setAggregateValue(partition)
self.assertEqual(str(instance.SoftwareInstance_hasReportedError()), '#error ')
instance.setAccessStatus("")
self.assertEqual(instance.SoftwareInstance_hasReportedError(), None)
def test_SoftwareInstallation_hasReportedError(self):
installation = self.portal.software_installation_module.newContent(
reference=self.generateNewId()
)
self.assertEqual(installation.SoftwareInstallation_hasReportedError(), None)
error_date = DateTime() - 0.1
with PinnedDateTime(self, error_date):
installation.setErrorStatus("")
self.assertNotEqual(installation.SoftwareInstallation_hasReportedError(), None)
self.assertEqual(
rfc1123_date(installation.SoftwareInstallation_hasReportedError()),
rfc1123_date(error_date))
installation.setBuildingStatus("")
self.assertEqual(installation.SoftwareInstallation_hasReportedError(), None)
class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin): class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
......
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: cell.getAggregateRelatedValue(portal_type="Software Instance").SoftwareInstance_hasReportedError(include_message=True, )</string> </value> <value> <string>python: cell.getAggregateRelatedValue(portal_type="Software Instance").SoftwareInstance_getReportedErrorDict()[\'message\']</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
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