Commit 195eb4cd authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: fixup InstanceTree_stopFromRegularisationRequest tests

parent 695a5d7c
...@@ -15,7 +15,8 @@ if (slap_state == 'start_requested'): ...@@ -15,7 +15,8 @@ if (slap_state == 'start_requested'):
software_type=instance_tree.getSourceReference(), software_type=instance_tree.getSourceReference(),
instance_xml=instance_tree.getTextContent(), instance_xml=instance_tree.getTextContent(),
sla_xml=instance_tree.getSlaXml(), sla_xml=instance_tree.getSlaXml(),
shared=instance_tree.isRootSlave() shared=instance_tree.isRootSlave(),
project_reference=instance_tree.getFollowUpReference()
) )
return True return True
return False return False
...@@ -420,29 +420,30 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep( ...@@ -420,29 +420,30 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
class TestSlapOSInstanceTree_stopFromRegularisationRequest( class TestSlapOSInstanceTree_stopFromRegularisationRequest(
SlapOSTestCaseMixinWithAbort): SlapOSTestCaseMixinWithAbort):
def createInstanceTree(self): def createInstanceTree(self, project):
new_id = self.generateNewId() new_id = self.generateNewId()
instance_tree = self.portal.instance_tree_module\ instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1) .template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit( instance_tree.edit(
reference="TESTHS-%s" % new_id, reference="TESTHS-%s" % new_id,
follow_up_value=project
) )
instance_tree.validate() instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor( self.portal.portal_workflow._jumpToStateFor(
instance_tree, 'start_requested') instance_tree, 'start_requested')
return instance_tree return instance_tree
def test_stopFromRegularisationRequest_REQUEST_disallowed(self): def test_stopFromRegularisationRequest_REQUESTdisallowed(self):
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.InstanceTree_stopFromRegularisationRequest, self.portal.InstanceTree_stopFromRegularisationRequest,
'', '',
REQUEST={}) REQUEST={})
def test_stopFromRegularisationRequest_matching_subscription(self): def test_stopFromRegularisationRequest_matchingSubscription(self):
project = self.addProject() project = self.addProject()
person = self.makePerson(project, index=0, user=0) person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree() instance_tree = self.createInstanceTree(project)
instance_tree.edit( instance_tree.edit(
destination_section=person.getRelativeUrl(), destination_section=person.getRelativeUrl(),
) )
...@@ -468,10 +469,10 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest( ...@@ -468,10 +469,10 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest(
self.assertEqual(instance_tree.isRootSlave(), shared) self.assertEqual(instance_tree.isRootSlave(), shared)
self.assertEqual(instance_tree.getSlapState(), "stop_requested") self.assertEqual(instance_tree.getSlapState(), "stop_requested")
def test_stopFromRegularisationRequest_stopped_subscription(self): def test_stopFromRegularisationRequest_stoppedSubscription(self):
project = self.addProject() project = self.addProject()
person = self.makePerson(project, index=0, user=0) person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree() instance_tree = self.createInstanceTree(project)
instance_tree.edit( instance_tree.edit(
destination_section=person.getRelativeUrl(), destination_section=person.getRelativeUrl(),
) )
...@@ -483,13 +484,15 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest( ...@@ -483,13 +484,15 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest(
self.assertEqual(result, False) self.assertEqual(result, False)
def test_stopFromRegularisationRequest_non_matching_person(self): def test_stopFromRegularisationRequest_nonMatchingPerson(self):
instance_tree = self.createInstanceTree() project = self.addProject()
instance_tree = self.createInstanceTree(project)
self.assertRaises( self.assertRaises(
AssertionError, AssertionError,
instance_tree.InstanceTree_stopFromRegularisationRequest, instance_tree.InstanceTree_stopFromRegularisationRequest,
'foobar') 'foobar')
class TestSlapOSInstanceTree_deleteFromRegularisationRequest( class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
SlapOSTestCaseMixinWithAbort): SlapOSTestCaseMixinWithAbort):
......
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