From 36c5dd6c1a3de4002d0808f7bf8ebb867706d18b Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 15 Oct 2018 12:31:27 +0200 Subject: [PATCH] Add test case for hard purge of images --- tests/plugins/images/test_views.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/plugins/images/test_views.py b/tests/plugins/images/test_views.py index aacd46ba..1888d8bf 100644 --- a/tests/plugins/images/test_views.py +++ b/tests/plugins/images/test_views.py @@ -1,4 +1,5 @@ import base64 +import os from io import BytesIO from django.core.files.uploadedfile import InMemoryUploadedFile @@ -199,6 +200,29 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB self.assertEqual(image.current_revision.previous_revision.revision_number, before_edit_rev) self.assertFalse(image.current_revision.deleted) + def test_purge(self): + """ + Tests that an image is really purged + """ + self._create_test_image(path='') + image = models.Image.objects.get() + image_revision = image.current_revision.imagerevision + f_path = image_revision.image.file.name + + self.assertTrue(os.path.exists(f_path)) + + response = self.client.post( + reverse('wiki:images_purge', kwargs={ + 'article_id': self.root_article, 'image_id': image.pk, 'path': '', + }), + data={'confirm': True} + ) + self.assertRedirects( + response, reverse('wiki:images_index', kwargs={'path': ''}) + ) + self.assertEqual(models.Image.objects.count(), 0) + self.assertFalse(os.path.exists(f_path)) + @wiki_override_settings(ACCOUNT_HANDLING=True) def test_login_on_revision_add(self): self._create_test_image(path='') -- 2.45.2