From 1dc931d736f06a4cc3bf2529c22ad64411bbd80a Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Tue, 9 Nov 2021 15:33:26 +0100 Subject: [PATCH] #19 Tests * adds EMA test --- ema/tests/test_views.py | 50 +++++++++++++++++++++++++++++--- intervention/tests/test_views.py | 1 + 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ema/tests/test_views.py b/ema/tests/test_views.py index 825dc4a1..0ab54e0d 100644 --- a/ema/tests/test_views.py +++ b/ema/tests/test_views.py @@ -120,6 +120,52 @@ class EmaViewTestCase(CompensationViewTestCase): self.assert_url_fail(client, fail_urls) self.assert_url_success(client, success_urls) + def test_logged_in_default_group_unshared(self): + """ Check correct status code for all requests + + OVERWRITES DEFAULT COMPENSATION TEST METHOD DUE TO SPECIFIC BEHAVIOUR OF EMAS + + Assumption: User logged in, is default group member and data is NOT shared + + Normally default group would give access to all base functionalities. In case of EMAs we expect these + requests to fail, since a user must be part of the ets group as well, not only default. + + We check on the same tests as in the _shared test, since we want to make sure there is no difference in + between shared and unshared, if the user is only part of the default group. + + Returns: + + """ + client = Client() + client.login(username=self.superuser.username, password=self.superuser_pw) + group = self.groups.get(name=DEFAULT_GROUP) + self.superuser.groups.set([group]) + + # Sharing does not have any effect in here, since the default group will prohibit further functionality access + # to this user + self.ema.users.set([]) + + success_urls = [ + self.index_url, + self.detail_url, + self.report_url, + ] + fail_urls = [ + self.new_url, + self.new_id_url, + self.edit_url, + self.state_new_url, + self.action_new_url, + self.deadline_new_url, + self.state_remove_url, + self.action_remove_url, + self.new_doc_url, + self.log_url, + self.remove_url, + ] + self.assert_url_fail(client, fail_urls) + self.assert_url_success(client, success_urls) + def test_logged_in_ets_group_shared(self): """ Check correct status code for all requests @@ -194,7 +240,3 @@ class EmaViewTestCase(CompensationViewTestCase): ] self.assert_url_success(client, success_urls) self.assert_url_fail(client, fail_urls) - - def test_logged_in_default_group_unshared(self): - # overwrite this test, since it's not relevant for EMA but is inherited by the superclass - pass \ No newline at end of file diff --git a/intervention/tests/test_views.py b/intervention/tests/test_views.py index f75bfe92..70a7077a 100644 --- a/intervention/tests/test_views.py +++ b/intervention/tests/test_views.py @@ -333,6 +333,7 @@ class InterventionViewTestCase(BaseViewTestCase): self.share_create_url, self.run_check_url, ] + # Define urls where a redirect to a specific location is the proper response success_urls_redirect = { self.share_url: self.detail_url }