Commit 526864c7 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: fixup InstanceTree_deleteFromRegularisationRequest tests

parent 195eb4cd
...@@ -15,7 +15,8 @@ if (slap_state in ['start_requested', 'stop_requested']): ...@@ -15,7 +15,8 @@ if (slap_state in ['start_requested', 'stop_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
...@@ -496,29 +496,30 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest( ...@@ -496,29 +496,30 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest(
class TestSlapOSInstanceTree_deleteFromRegularisationRequest( class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
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_deleteFromRegularisationRequest_REQUEST_disallowed(self): def test_deleteFromRegularisationRequest_REQUESTdisallowed(self):
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.InstanceTree_deleteFromRegularisationRequest, self.portal.InstanceTree_deleteFromRegularisationRequest,
'', '',
REQUEST={}) REQUEST={})
def test_deleteFromRegularisationRequest_started_subscription(self): def test_deleteFromRegularisationRequest_startedSubscription(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(),
) )
...@@ -544,10 +545,10 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest( ...@@ -544,10 +545,10 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
self.assertEqual(instance_tree.isRootSlave(), shared) self.assertEqual(instance_tree.isRootSlave(), shared)
self.assertEqual(instance_tree.getSlapState(), "destroy_requested") self.assertEqual(instance_tree.getSlapState(), "destroy_requested")
def test_deleteFromRegularisationRequest_stopped_subscription(self): def test_deleteFromRegularisationRequest_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(),
) )
...@@ -575,10 +576,10 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest( ...@@ -575,10 +576,10 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
self.assertEqual(instance_tree.isRootSlave(), shared) self.assertEqual(instance_tree.isRootSlave(), shared)
self.assertEqual(instance_tree.getSlapState(), "destroy_requested") self.assertEqual(instance_tree.getSlapState(), "destroy_requested")
def test_deleteFromRegularisationRequest_destroyed_subscription(self): def test_deleteFromRegularisationRequest_destroyedSubscription(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(),
) )
...@@ -590,8 +591,9 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest( ...@@ -590,8 +591,9 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
self.assertEqual(result, False) self.assertEqual(result, False)
def test_deleteFromRegularisationRequest_non_matching_person(self): def test_deleteFromRegularisationRequest_nonMatchingPerson(self):
instance_tree = self.createInstanceTree() project = self.addProject()
instance_tree = self.createInstanceTree(project)
self.assertRaises( self.assertRaises(
AssertionError, AssertionError,
instance_tree.InstanceTree_deleteFromRegularisationRequest, instance_tree.InstanceTree_deleteFromRegularisationRequest,
......
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