def test_update_get_successurl(self):
     updateview = EconsensusActionitemUpdateView()
     updateview.object = ActionItem(id=1)
     updateview.kwargs = {'decisionpk': 1}
     assert updateview.get_success_url() == reverse('actionitem_detail',
                                                    kwargs={
                                                        'decisionpk': 1,
                                                        'pk': 1
                                                    })
 def test_update_login_and_editor_not_logged_in(self):
     get_request = RequestFactory().get('/')
     user = User.objects.create()
     user.is_authenticated = lambda: False
     get_request.user = user
     response = EconsensusActionitemUpdateView.as_view()(get_request)
     assert response.status_code == 302  # Redirects to login
     user.delete()
Ejemplo n.º 3
0
 def test_update_login_and_editor_not_logged_in(self):
     get_request = RequestFactory().get('/')
     user = User.objects.create()
     user.is_authenticated = lambda: False
     get_request.user = user
     response = EconsensusActionitemUpdateView.as_view()(get_request)
     assert response.status_code == 302  # Redirects to login
     user.delete()
 def test_update_login_and_editor(self):
     decision = self.create_and_return_decision()
     actionitem = ActionItem.objects.create()
     get_request = RequestFactory().get('/')
     get_request.user = self.betty
     response = EconsensusActionitemUpdateView.as_view()(
         get_request, decisionpk=decision.pk, pk=actionitem.pk
     )  # The decisionpk is what django-guardian checks for
     assert response.status_code == 200
     decision.delete()
     actionitem.delete()
Ejemplo n.º 5
0
 def test_update_login_and_editor(self):
     decision = self.create_and_return_decision()
     actionitem = ActionItem.objects.create()
     get_request = RequestFactory().get('/')
     get_request.user = self.betty
     response = EconsensusActionitemUpdateView.as_view()(
         get_request, decisionpk=decision.pk, pk=actionitem.pk
     )  # The decisionpk is what django-guardian checks for
     assert response.status_code == 200
     decision.delete()
     actionitem.delete()
 def test_update_login_and_editor_noeditor_perms(self):
     decision = self.create_and_return_decision()
     actionitem = ActionItem.objects.create()
     get_request = RequestFactory().get('/')
     assert self.charlie.is_authenticated()  # Confirm user is logged in
     get_request.user = self.charlie
     response = EconsensusActionitemUpdateView.as_view()(
         get_request, decisionpk=decision.pk, pk=actionitem.pk
     )  # The decisionpk is what django-guardian checks for
     assert response.status_code == 403
     decision.delete()
     actionitem.delete()
Ejemplo n.º 7
0
 def test_update_login_and_editor_noeditor_perms(self):
     decision = self.create_and_return_decision()
     actionitem = ActionItem.objects.create()
     get_request = RequestFactory().get('/')
     assert self.charlie.is_authenticated()  # Confirm user is logged in
     get_request.user = self.charlie
     response = EconsensusActionitemUpdateView.as_view()(
         get_request, decisionpk=decision.pk, pk=actionitem.pk
     )  # The decisionpk is what django-guardian checks for
     assert response.status_code == 403
     decision.delete()
     actionitem.delete()
Ejemplo n.º 8
0
 def test_update_form_kwargs_contain_prefix(self):
     updateview = EconsensusActionitemUpdateView()
     updateview.object = ActionItem(id=1)
     updateview.request = RequestFactory().get('/')
     updateview.kwargs = {'decisionpk': 1}
     form_kwargs = updateview.get_form_kwargs()
     assert 'prefix' in form_kwargs
     assert form_kwargs['prefix'] == "actionitem-1"
Ejemplo n.º 9
0
 def test_update_get_successurl(self):
     updateview = EconsensusActionitemUpdateView()
     updateview.object = ActionItem(id=1)
     updateview.kwargs = {'decisionpk': 1}
     assert updateview.get_success_url() == reverse('actionitem_detail', kwargs={'decisionpk': 1, 'pk': 1})