From bcad4e005382913e3532dc5fbe63c319961fbb30 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 23 Jun 2024 10:28:18 -0700 Subject: [PATCH] Update test --- src/documents/tests/test_file_handling.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.py index dd2c59f07..e13cd866d 100644 --- a/src/documents/tests/test_file_handling.py +++ b/src/documents/tests/test_file_handling.py @@ -573,7 +573,19 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase): @override_settings(FILENAME_FORMAT="{title}") @mock.patch("documents.signals.handlers.Document.objects.filter") - def test_no_update_without_change(self, m): + @mock.patch("documents.signals.handlers.shutil.move") + def test_no_move_only_save(self, mock_move, mock_filter): + """ + GIVEN: + - A document with a filename + - The document is saved + - The filename is not changed + WHEN: + - The document is saved + THEN: + - The document modified date is updated + - The document is not moved + """ with disable_auditlog(): doc = Document.objects.create( title="document", @@ -583,12 +595,16 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase): archive_checksum="B", mime_type="application/pdf", ) + original_modified = doc.modified Path(doc.source_path).touch() Path(doc.archive_path).touch() doc.save() + doc.refresh_from_db() - m.assert_not_called() + mock_filter.assert_called() + self.assertNotEqual(original_modified, doc.modified) + mock_move.assert_not_called() class TestFileHandlingWithArchive(DirectoriesMixin, FileSystemAssertsMixin, TestCase):