Esempio n. 1
0
 def test_redirect_anonymous(self, method, *args):
     # WHEN anonymous user send request to monitorings page
     request = MagicMock(user=self.users['anonymous'], method=method)
     request.get_full_path.return_value = self.url
     response = monitorings_list(request)
     # THEN response status_code should be 302 (redirect)
     self.assertEqual(response.status_code, 302)
     # AND response redirects to login page
     self.assertEqual(response['Location'],
                      '{}?next={}'.format(settings.LOGIN_URL, self.url))
Esempio n. 2
0
 def test_allow_post(self, username, *args):
     # WHEN admin or any expert changes columns visibility settings on monitorings page
     data = {
         'mon_evaluation_start': True,
         'mon_interact_start': False,
         'mon_interact_end': True,
         'mon_publish_date': False,
         'columns_picker_submit': True
     }
     request = MagicMock(user=self.users[username],
                         method='POST',
                         POST=data)
     request.get_full_path.return_value = self.url
     response = monitorings_list(request)
     # THEN response status_code should be 302 (redirect)
     self.assertEqual(response.status_code, 302)
Esempio n. 3
0
 def test_allow_get_with_params(self, param, *args):
     # WHEN admin or any expert get monitorings page
     request = MagicMock(user=self.users['expertA'], method='GET')
     response = monitorings_list(request, param)
     # THEN response status_code should be 200 (OK)
     self.assertEqual(response.status_code, 200)
Esempio n. 4
0
 def test_allow_get(self, username, *args):
     # WHEN admin or any expert get monitorings page
     request = MagicMock(user=self.users[username], method='GET')
     response = monitorings_list(request)
     # THEN response status_code should be 200 (OK)
     self.assertEqual(response.status_code, 200)