Commit d178ebe9 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: lint test

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