Commit 37db91b1 authored by Łukasz Nowak's avatar Łukasz Nowak

Cover more cases.

Prove that trying to request with same title will fail (test_request_sameTitle).

Prove that shared parameter is correctly supported and system complains in case
if its type is incorrect (test_request_shared_True and test_request_shared_unsupported).

Prove that indexation will not result in damaged system (test_request_unindexed).

Prove that in case of normal request with same coordinates same instance is returned
(test_request_double).

Prove that in case if there is damage in system (same tree contains one then
more instance with same title) no more requests will be allowed (test_request_duplicated).
parent 1995f3c0
...@@ -148,3 +148,171 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin): ...@@ -148,3 +148,171 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
requested_instance.getSlaXml()) requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'], self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference()) requested_instance.getSourceReference())
def test_request_sameTitle(self):
# check that correct request does not raise
self.assertRaises(ValueError, self.software_instance.requestInstance,
**self.request_kw)
def test_request_shared_True(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Slave Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getRootSoftwareReleaseUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
def test_request_shared_unsupported(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = 'True'
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
def test_request_unindexed(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getRootSoftwareReleaseUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
transaction.commit()
self.assertRaises(NotImplementedError, self.software_instance.requestInstance,
**request_kw)
def test_request_double(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getRootSoftwareReleaseUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
self.tic()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance2)
self.assertEqual(requested_instance2.getRelativeUrl(),
requested_instance.getRelativeUrl())
self.assertEqual(request_kw['software_title'],
requested_instance2.getTitle())
self.assertEqual('Software Instance',
requested_instance2.getPortalType())
self.assertEqual('validated',
requested_instance2.getValidationState())
self.assertEqual('start_requested',
requested_instance2.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance2.getRootSoftwareReleaseUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
def test_request_duplicated(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
duplicate = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate, 'start_requested')
duplicate2 = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate2.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate2.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate2, 'start_requested')
self.software_instance.getSpecialiseValue(\
portal_type='Hosting Subscription').edit(
predecessor_list=[
duplicate.getRelativeUrl(),
duplicate2.getRelativeUrl(),
self.software_instance.getRelativeUrl()
]
)
self.tic()
# check that correct request does not raise
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
70 71
\ No newline at end of file \ No newline at end of file
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