Commit a2f90846 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: test: simplify

parent e0110082
......@@ -596,93 +596,23 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
class TestSlapOSHasError(SlapOSTestCaseMixin):
def makeSoftwareRelease(self, software_release_url=None):
software_release = self.portal.software_release_module\
.template_software_release.Base_createCloneDocument(batch_mode=1)
new_id = self.generateNewId()
software_release.edit(
url_string=software_release_url or self.generateNewSoftwareReleaseUrl(),
reference='TESTSOFTRELS-%s' % new_id,
title='Start requested for %s' % new_id
)
software_release.release()
return software_release
def _makeSoftwareInstallation(self, software_release_url):
software_installation = self.portal\
.software_installation_module.template_software_installation\
.Base_createCloneDocument(batch_mode=1)
new_id = self.generateNewId()
software_installation.edit(
url_string=software_release_url,
aggregate=self.compute_node.getRelativeUrl(),
reference='TESTSOFTINSTS-%s' % new_id,
title='Start requested for %s' % self.compute_node.getUid()
)
software_installation.validate()
software_installation.requestStart()
return software_installation
def _makeSoftwareInstance(self, instance_tree, software_url):
kw = dict(
software_release=software_url,
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=instance_tree.getTitle(),
state='started'
)
instance_tree.requestStart(**kw)
instance_tree.requestInstance(**kw)
def _makeInstanceTree(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
instance_tree = self.portal\
.instance_tree_module.template_instance_tree\
.Base_createCloneDocument(batch_mode=1)
instance_tree.validate()
new_id = self.generateNewId()
instance_tree.edit(
title= "Test hosting sub ticket %s" % new_id,
reference="TESTHST-%s" % new_id,
destination_section_value=person
)
return instance_tree
def _makeComputePartitionList(self):
for i in range(1, 5):
id_ = 'partition%s' % (i, )
p = self.compute_node.newContent(portal_type='Compute Partition',
id=id_,
title=id_,
reference=id_,
default_network_address_ip_address='ip_address_%s' % i,
default_network_address_netmask='netmask_%s' % i)
p.markFree()
p.validate()
def test_SoftwareInstance_hasReportedError(self):
instance_tree = self._makeInstanceTree()
self._makeSoftwareInstance(instance_tree,
self.generateNewSoftwareReleaseUrl())
instance = instance_tree.getSuccessorValue()
instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
reference=self.generateNewId()
)
_, partition = self._makeComputeNode(self.addProject())
self._makeComputeNode(self.project)
self._makeComputePartitionList()
error_date = DateTime()
try:
self.pinDateTime(error_date)
instance.setErrorStatus("")
finally:
self.unpinDateTime()
instance.setErrorStatus("")
self.assertEqual(instance.SoftwareInstance_hasReportedError(), None)
instance.setAggregateValue(self.compute_node.partition1)
instance.setAggregateValue(partition)
self.assertEqual(str(instance.SoftwareInstance_hasReportedError()), '#error ')
......@@ -690,11 +620,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self.assertEqual(instance.SoftwareInstance_hasReportedError(), None)
def test_SoftwareInstallation_hasReportedError(self):
software_release = self.makeSoftwareRelease()
self._makeComputeNode(self.project)
installation = self._makeSoftwareInstallation(
software_release.getUrlString()
)
installation = self.portal.software_installation_module.newContent()
self.assertEqual(installation.SoftwareInstallation_hasReportedError(), None)
......@@ -713,7 +639,6 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self.assertEqual(installation.SoftwareInstallation_hasReportedError(), None)
class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
def afterSetUp(self):
......
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