Esempio n. 1
0
 def test_get_create_composer_anonymous(self):
     """Get the create composer form as an anoynmous user"""
     request = self.request_factory.get(reverse('foia-create'))
     request.user = AnonymousUser()
     request = mock_middleware(request)
     response = CreateComposer.as_view()(request)
     eq_(response.status_code, 200)
Esempio n. 2
0
 def test_get_create_composer(self):
     """Get the create composer form"""
     request = self.request_factory.get(reverse('foia-create'))
     request.user = UserFactory()
     request = mock_middleware(request)
     response = CreateComposer.as_view()(request)
     eq_(response.status_code, 200)
Esempio n. 3
0
 def test_get_create_composer_clone(self):
     """Test cloning a composer"""
     clone = FOIARequestFactory()
     request = self.request_factory.get(
         reverse("foia-create") + "?clone={}".format(clone.composer.pk))
     request.user = UserFactory()
     request = mock_middleware(request)
     response = CreateComposer.as_view()(request)
     eq_(response.status_code, 200)
     eq_(response.context_data["form"].initial["title"],
         clone.composer.title)
Esempio n. 4
0
 def test_post_create_composer_anonymous(self):
     """Create a new composer as an anonymous user"""
     agency = AgencyFactory()
     data = {
         'title': 'Title',
         'requested_docs': 'ABC',
         'agencies': agency.pk,
         'action': 'save',
         'register_full_name': 'John Doe',
         'register_email': '*****@*****.**',
     }
     request = self.request_factory.post(reverse('foia-create'), data)
     request.user = AnonymousUser()
     request = mock_middleware(request)
     response = CreateComposer.as_view()(request)
     eq_(response.status_code, 302)
     user = User.objects.get(email='*****@*****.**')
     ok_(user.composers.get(title='Title'))
Esempio n. 5
0
 def test_post_create_composer_anonymous(self):
     """Create a new composer as an anonymous user"""
     agency = AgencyFactory()
     data = {
         "title": "Title",
         "requested_docs": "ABC",
         "agencies": agency.pk,
         "action": "save",
         "register_full_name": "John Doe",
         "register_email": "*****@*****.**",
         "stripe_pk": "STRIPE_PK",
     }
     request = self.request_factory.post(reverse("foia-create"), data)
     request.user = AnonymousUser()
     request = mock_middleware(request)
     response = CreateComposer.as_view()(request)
     eq_(response.status_code, 302)
     user = User.objects.get(email="*****@*****.**")
     ok_(user.composers.get(title="Title"))