Exemplo n.º 1
0
 def test_post_update_composer(self):
     """Test submitting a composer"""
     composer = FOIAComposerFactory(
         status='started',
         user__profile__num_requests=4,
     )
     agency = AgencyFactory()
     data = {
         'title': 'Title',
         'requested_docs': 'ABC',
         'agencies': agency.pk,
         'action': 'submit',
     }
     request = self.request_factory.post(
         reverse('foia-draft', kwargs={
             'idx': composer.pk
         }),
         data,
     )
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 302)
     composer.refresh_from_db()
     ok_(composer.status, 'submitted')
Exemplo n.º 2
0
 def test_get_update_composer_bad(self):
     """Try to update a composer that can no longer be updated"""
     composer = FOIAComposerFactory(status='filed')
     request = self.request_factory.get(
         reverse('foia-draft', kwargs={'idx': composer.pk}))
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 302)
Exemplo n.º 3
0
 def test_get_update_composer(self):
     """Get the update composer form"""
     composer = FOIAComposerFactory()
     request = self.request_factory.get(
         reverse('foia-draft', kwargs={'idx': composer.pk}))
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 200)
Exemplo n.º 4
0
 def test_post_delete_update_composer(self):
     """Test deleting a composer"""
     composer = FOIAComposerFactory(status="started")
     data = {"action": "delete"}
     request = self.request_factory.post(
         reverse("foia-draft", kwargs={"idx": composer.pk}), data)
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 302)
     assert_false(FOIAComposer.objects.filter(pk=composer.pk).exists())
Exemplo n.º 5
0
 def test_get_update_composer_revoke(self):
     """Get the update composer form for a recently submitted composer"""
     composer = FOIAComposerFactory(status="submitted",
                                    delayed_id="123",
                                    datetime_submitted=timezone.now())
     request = self.request_factory.get(
         reverse("foia-draft", kwargs={"idx": composer.pk}))
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 200)
     composer.refresh_from_db()
     eq_(composer.status, "started")
Exemplo n.º 6
0
 def test_post_delete_update_composer(self):
     """Test deleting a composer"""
     composer = FOIAComposerFactory(
         status='started',
         user__profile__num_requests=4,
     )
     data = {
         'action': 'delete',
     }
     request = self.request_factory.post(
         reverse('foia-draft', kwargs={'idx': composer.pk}),
         data,
     )
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 302)
     assert_false(FOIAComposer.objects.filter(pk=composer.pk).exists())
Exemplo n.º 7
0
 def test_post_update_composer(self):
     """Test submitting a composer"""
     composer = FOIAComposerFactory(status="started")
     agency = AgencyFactory()
     data = {
         "title": "Title",
         "requested_docs": "ABC",
         "agencies": agency.pk,
         "action": "submit",
         "stripe_pk": "STRIPE_PK",
     }
     request = self.request_factory.post(
         reverse("foia-draft", kwargs={"idx": composer.pk}), data)
     request.user = composer.user
     request = mock_middleware(request)
     response = UpdateComposer.as_view()(request, idx=composer.pk)
     eq_(response.status_code, 302)
     composer.refresh_from_db()
     ok_(composer.status, "submitted")