From b1f4a23679de9a561ed8ec3be9b79e851873bc0f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sat, 9 Mar 2019 15:58:12 +0100 Subject: Fix document deletion - tests --- archaeological_operations/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'archaeological_operations/tests.py') diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 3f35de73b..e1f29b293 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -37,6 +37,7 @@ from django.contrib.auth.models import User, Permission from django.utils.translation import ugettext_lazy as _, pgettext, pgettext_lazy from . import models +from ishtar_common.views import document_deletion_steps from archaeological_operations import views from ishtar_common.models import OrganizationType, Organization, ItemKey, \ @@ -2805,3 +2806,33 @@ class DocumentTest(OperationInitTest, TestCase): self.assertIn(posted["title"], response.content.decode()) +class DocumentWizardDeleteTest(WizardTest, OperationInitTest, TestCase): + fixtures = FILE_FIXTURES + url_name = 'document_deletion' + url_uri = "document/delete" + wizard_name = 'document_deletion_wizard' + steps = document_deletion_steps + form_datas = [ + FormData( + "Delete document", + form_datas={ + 'selec': {'pk': None}, + }, + ), + ] + + def pre_wizard(self): + ope = self.get_default_operation() + document = Document.objects.create(title="testy") + document.operations.add(ope) + self.ope_id = ope.pk + self.form_datas[0].set('selec', 'pk', document.pk) + self.doc_nb = Document.objects.count() + super(DocumentWizardDeleteTest, self).pre_wizard() + + def post_wizard(self): + self.assertEqual(Document.objects.count(), + self.doc_nb - 1) + # operation not deleted with the document + self.assertEqual(models.Operation.objects.filter( + pk=self.ope_id).count(), 1) -- cgit v1.2.3