Esempio n. 1
0
    def setUp(self):
        owner = UserFactory.create()
        self.investigation = InvestigationFactory.create()
        self.investigation.add_user(owner, INVESTIGATION_ROLES.OWNER)

        self.form = FormFactory(investigation=self.investigation)
        self.client.force_login(owner)
Esempio n. 2
0
    def test_owner_of_other_investigation_cannot_create(self):
        self.client.force_login(self.investigation_owner)
        other_form = FormFactory.create()

        response = self.client.post(make_url(other_form),
                                    {"form_json": {}},
                                    format="json")
        self.assertEqual(response.status_code, 403)
    def test_can_get_form(self):
        admin = UserFactory.create()
        investigation = InvestigationFactory.create()
        investigation.add_user(admin, INVESTIGATION_ROLES.ADMIN)
        form = FormFactory.create(investigation=investigation)

        self.client.force_login(admin)

        response = self.client.get(
            reverse("form_details", kwargs={"form_slug": form.slug}))
        self.assertEqual(response.status_code, 200)
    def test_get_wrong_investigation(self):
        admin = UserFactory.create()
        investigation = InvestigationFactory.create()
        investigation.add_user(admin, INVESTIGATION_ROLES.ADMIN)
        form = FormFactory.create(
        )  # this will be part of another investigation

        self.client.force_login(admin)

        response = self.client.get(
            reverse("form_details", kwargs={"form_slug": form.slug}))
        self.assertEqual(response.status_code, 403)
    def test_admin_can_edit(self):
        admin = UserFactory.create()
        investigation = InvestigationFactory.create()
        investigation.add_user(admin, INVESTIGATION_ROLES.ADMIN)
        form = FormFactory.create(investigation=investigation)

        self.client.force_login(admin)

        response = self.client.patch(reverse("form_details",
                                             kwargs={"form_slug": form.slug}),
                                     data={"name": "My new Name"})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.data["name"], "My new Name")
Esempio n. 6
0
 def test_submissions_by_date_no_submissions(self):
     form = FormFactory.create()
     self.assertQuerysetEqual(form.submissions_by_date(), [])
Esempio n. 7
0
 def setUp(self):
     self.investigation_owner = UserFactory.create()
     self.investigation = InvestigationFactory.create()
     self.form = FormFactory.create(investigation=self.investigation)
     self.investigation.add_user(self.investigation_owner, INVESTIGATION_ROLES.OWNER)
    def test_get_requires_login(self):
        form = FormFactory.create()

        response = self.client.get(
            reverse("form_details", kwargs={"form_slug": form.slug}))
        self.assertEqual(response.status_code, 403)