From 446d59766ba26533559082f3dbd41c845a07252e Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Tue, 13 Mar 2018 23:12:09 +0100 Subject: [PATCH] Added some tests for the AttachmentRevision model. --- tests/plugins/attachments/test_models.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/plugins/attachments/test_models.py diff --git a/tests/plugins/attachments/test_models.py b/tests/plugins/attachments/test_models.py new file mode 100644 index 00000000..5c5ef4e3 --- /dev/null +++ b/tests/plugins/attachments/test_models.py @@ -0,0 +1,31 @@ +from tests.base import RequireRootArticleMixin, TestBase +from wiki.plugins.attachments.models import AttachmentRevision, Attachment + + +class AttachmentRevisionTests(RequireRootArticleMixin, TestBase): + + def setUp(self): + super().setUp() + self.attachment = Attachment.objects.create( + article=self.root_article, original_filename='blah.txt', + ) + self.revision = AttachmentRevision.objects.create( + attachment=self.attachment, file=None, description='muh', + revision_number=1, + ) + + def test_revision_no_file(self): + # Intentionally, there are no asserts, as the test just needs to + # target an if-branch in the pre-delete signal for AttachmentRevision + self.revision.delete() + + def test_revision_file_size(self): + self.assertIsNone(self.revision.get_size()) + + def test_get_filename_no_file(self): + self.assertIsNone(self.revision.get_filename()) + + def test_str(self): + self.assertEqual(str(self.revision), "%s: %s (r%d)" % ( + 'Root Article', 'blah.txt', 1, + )) -- 2.45.2