Commit d178ebe9 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: lint test

parent e7c72fb0
......@@ -42,7 +42,8 @@ class TestSlapOSPerson_checkToCreateRegularisationRequest(SlapOSTestCaseMixinWit
if preference.getPreferenceState() == 'global':
preference.setPreferredSlaposWebSiteUrl('http://foobar.org/')
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
before_date = DateTime()
ticket, event = person.Person_checkToCreateRegularisationRequest()
after_date = DateTime()
......@@ -94,7 +95,8 @@ The slapos team
if preference.getPreferenceState() == 'global':
preference.setPreferredSlaposWebSiteUrl('http://foobar.org/')
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
new_id = self.generateNewId()
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
......@@ -147,7 +149,8 @@ The slapos team
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_do_not_duplicate_ticket_if_not_reindexed(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket, event = person.Person_checkToCreateRegularisationRequest()
transaction.commit()
ticket2, event2 = person.Person_checkToCreateRegularisationRequest()
......@@ -161,14 +164,16 @@ The slapos team
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_addRegularisationRequest_balance_ok(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket, event = person.Person_checkToCreateRegularisationRequest()
self.assertEqual(ticket, None)
self.assertEqual(event, None)
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_existing_suspended_ticket(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket, event = person.Person_checkToCreateRegularisationRequest()
transaction.commit()
self.tic()
......@@ -180,7 +185,8 @@ The slapos team
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_existing_validated_ticket(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket, event = person.Person_checkToCreateRegularisationRequest()
ticket.validate()
transaction.commit()
......@@ -193,7 +199,8 @@ The slapos team
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_existing_invalidated_ticket(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = person.Person_checkToCreateRegularisationRequest()[0]
ticket.invalidate()
transaction.commit()
......@@ -203,7 +210,8 @@ The slapos team
self.assertNotEqual(event2, None)
def test_addRegularisationRequest_REQUEST_disallowed(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
self.assertRaises(
Unauthorized,
person.Person_checkToCreateRegularisationRequest,
......@@ -230,7 +238,8 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "0"')
def test_invalidateIfPersonBalanceIsOk_matching_case(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(source_project_value=person)
ticket.validate()
......@@ -240,7 +249,8 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "0"')
def test_invalidateIfPersonBalanceIsOk_validated(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(source_project_value=person)
ticket.validate()
......@@ -257,7 +267,8 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_invalidateIfPersonBalanceIsOk_wrong_balance(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(source_project_value=person)
ticket.validate()
......@@ -277,7 +288,8 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
)
def test_checkToSendUniqEvent_no_event(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
......@@ -313,7 +325,8 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
)
def test_checkToSendUniqEvent_call_twice_with_tic(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
......@@ -332,7 +345,8 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event.getRelativeUrl(), event2.getRelativeUrl())
def test_checkToSendUniqEvent_manual_event(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
......@@ -357,7 +371,8 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event.getRelativeUrl(), event2.getRelativeUrl())
def test_checkToSendUniqEvent_not_suspended(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
......@@ -370,7 +385,8 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event, None)
def test_checkToSendUniqEvent_event_not_reindexed(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
......@@ -927,7 +943,8 @@ class TestSlapOSRegularisationRequest_stopInstanceTreeList(
'comment="Visited by InstanceTree_stopFromRegularisationRequest ' \
'%s" % (person))')
def test_stopInstanceTreeList_matching_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
instance_tree = self.createInstanceTree()
......@@ -959,7 +976,8 @@ class TestSlapOSRegularisationRequest_stopInstanceTreeList(
'comment="Visited by InstanceTree_stopFromRegularisationRequest ' \
'%s" % (person))')
def test_stopInstanceTreeList_matching_subscription_2(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
instance_tree = self.createInstanceTree()
......@@ -988,7 +1006,8 @@ class TestSlapOSRegularisationRequest_stopInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_stopInstanceTreeList_other_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......@@ -1031,7 +1050,8 @@ class TestSlapOSRegularisationRequest_stopInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_stopInstanceTreeList_not_suspended(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......@@ -1053,7 +1073,8 @@ class TestSlapOSRegularisationRequest_stopInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_stopInstanceTreeList_other_resource(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......@@ -1095,7 +1116,8 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest(
REQUEST={})
def test_stopFromRegularisationRequest_matching_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
......@@ -1123,7 +1145,8 @@ class TestSlapOSInstanceTree_stopFromRegularisationRequest(
self.assertEqual(instance_tree.getSlapState(), "stop_requested")
def test_stopFromRegularisationRequest_stopped_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
......@@ -1166,7 +1189,8 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
REQUEST={})
def test_deleteFromRegularisationRequest_started_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
......@@ -1194,7 +1218,8 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
self.assertEqual(instance_tree.getSlapState(), "destroy_requested")
def test_deleteFromRegularisationRequest_stopped_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
......@@ -1224,7 +1249,8 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
self.assertEqual(instance_tree.getSlapState(), "destroy_requested")
def test_deleteFromRegularisationRequest_destroyed_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
instance_tree = self.createInstanceTree()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
......@@ -1283,7 +1309,8 @@ class TestSlapOSRegularisationRequest_deleteInstanceTreeList(
'comment="Visited by InstanceTree_deleteFromRegularisationRequest ' \
'%s" % (person))')
def test_deleteInstanceTreeList_matching_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
instance_tree = self.createInstanceTree()
......@@ -1312,7 +1339,8 @@ class TestSlapOSRegularisationRequest_deleteInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_other_subscription(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......@@ -1355,7 +1383,8 @@ class TestSlapOSRegularisationRequest_deleteInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_not_suspended(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......@@ -1377,7 +1406,8 @@ class TestSlapOSRegularisationRequest_deleteInstanceTreeList(
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_other_resource(self):
person = self.makePerson(index=0, user=0)
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
......
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