#19 Tests
* refactors sharing user setting by introducing share_with(user) and share_with_list(user_list) for BaseObject for a more self-explanatory sharing
This commit is contained in:
@@ -116,7 +116,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
default_group = Group.objects.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([default_group])
|
||||
self.intervention.users.set([self.superuser])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -156,7 +156,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
default_group = Group.objects.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([default_group])
|
||||
self.intervention.users.set([])
|
||||
self.intervention.share_with_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -196,7 +196,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to zb group
|
||||
zb_group = self.groups.get(name=ZB_GROUP)
|
||||
self.superuser.groups.set([zb_group])
|
||||
self.intervention.users.set([self.superuser])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -236,7 +236,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to zb group
|
||||
zb_group = self.groups.get(name=ZB_GROUP)
|
||||
self.superuser.groups.set([zb_group])
|
||||
self.intervention.users.set([])
|
||||
self.intervention.share_with_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -276,7 +276,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to ets group
|
||||
ets_group = Group.objects.get(name=ETS_GROUP)
|
||||
self.superuser.groups.set([ets_group])
|
||||
self.intervention.users.set([self.superuser])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -316,7 +316,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
ets_group = Group.objects.get(name=ETS_GROUP)
|
||||
self.superuser.groups.set([ets_group])
|
||||
self.intervention.users.set([])
|
||||
self.intervention.share_with_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
|
||||
@@ -26,8 +26,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
def setUpTestData(cls):
|
||||
super().setUpTestData()
|
||||
|
||||
# Give the user shared access to the dummy intervention
|
||||
cls.intervention.users.add(cls.superuser)
|
||||
cls.intervention.share_with(cls.superuser)
|
||||
|
||||
def test_new(self):
|
||||
"""
|
||||
@@ -312,7 +311,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
|
||||
# Now restore the deductable surface to a valid size back again but remove the user from the shared list
|
||||
self.eco_account.deductable_surface = test_surface + 100.00
|
||||
self.eco_account.users.set([])
|
||||
self.eco_account.share_with_list([])
|
||||
self.eco_account.save()
|
||||
|
||||
# Now perform the (expected) failing request (again)
|
||||
@@ -323,7 +322,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.assertEqual(num_deductions_total, EcoAccountDeduction.objects.count())
|
||||
|
||||
# Restore the sharing but remove the recording state
|
||||
self.eco_account.users.set([self.superuser])
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.recorded.delete()
|
||||
self.eco_account.refresh_from_db()
|
||||
self.eco_account.save()
|
||||
@@ -354,7 +353,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
action=UserAction.RECORDED
|
||||
)
|
||||
self.eco_account.recorded = rec_action
|
||||
self.eco_account.users.set([self.superuser])
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.save()
|
||||
|
||||
# Run the request
|
||||
|
||||
Reference in New Issue
Block a user