From a589b3ef96c9adf4e408713201ffe7d269e4f78f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 18 Apr 2023 17:21:38 +0200 Subject: Document -> Town/Area: models, admin, forms --- ishtar_common/tests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'ishtar_common/tests.py') diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 7328a5f95..4e450c3f8 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3821,9 +3821,41 @@ class DocumentTest(TestCase): self.find2.base_finds.add(bf2) self.st1 = models.SourceType.objects.create(label="Report", code="REP") self.st2 = models.SourceType.objects.create(label="Illustration", code="ILL") + self.town = models.Town.objects.create(name="Daisy town", numero_insee="59134") self.username, self.password, self.user = create_superuser() + def test_create_form(self): + nb_doc = models.Document.objects.count() + c = Client() + url = reverse("create-document") + response = c.get(url) + self.assertEqual(response.status_code, 302) + + c.login(username=self.username, password=self.password) + response = c.get(url) + self.assertEqual(response.status_code, 200) + + posted = { + "authors": [], + "title": "A document", + "operations": [str(self.ope1.pk)], + "towns": [str(self.town.pk)], + } + response = c.post(url, posted) + new_child_document = self.ope1.documents.order_by("-pk").all()[0] + self.assertEqual(nb_doc + 1, models.Document.objects.count()) + self.assertRedirects( + response, + "/document/edit/?open_item={}".format( + new_child_document.pk + ), + ) + self.assertIn( + self.town.pk, + list(new_child_document.towns.values_list("pk", flat=True).all()) + ) + def test_custom_index(self): profile, created = models.IshtarSiteProfile.objects.get_or_create( slug="default", active=True -- cgit v1.2.3