From 0f97a23c6b996d6519517743ca72c711f973f5a9 Mon Sep 17 00:00:00 2001 From: rafalp Date: Sat, 11 Jan 2025 12:49:33 +0100 Subject: [PATCH] Test in edit formsets skipping deleted attachments --- misago/conftest.py | 2 ++ misago/posting/tests/test_formsets.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/misago/conftest.py b/misago/conftest.py index 630d8ed1e..db8f7c600 100644 --- a/misago/conftest.py +++ b/misago/conftest.py @@ -536,6 +536,7 @@ def _attachment_factory( uploader=None, post=None, thumbnail_path=None, + is_deleted=False, ): filename = filename or str(os.path.split(file_path)[-1]) filetype = filetypes.match_filetype(filename) @@ -583,6 +584,7 @@ def _attachment_factory( image=image, video=video, file=file, + is_deleted=is_deleted, ) return _attachment_factory diff --git a/misago/posting/tests/test_formsets.py b/misago/posting/tests/test_formsets.py index 9fb42cffd..ca09076bb 100644 --- a/misago/posting/tests/test_formsets.py +++ b/misago/posting/tests/test_formsets.py @@ -355,6 +355,9 @@ def test_get_edit_thread_formset_loads_post_attachments( attachment_factory(text_file, uploader=other_user, post=other_thread.first_post) attachment_factory(text_file, uploader=user) attachment_factory(text_file, uploader=other_user) + attachment_factory( + text_file, uploader=user, post=thread.first_post, is_deleted=True + ) formset = get_edit_thread_formset(request, thread.first_post) assert formset.title @@ -459,6 +462,12 @@ def test_get_edit_private_thread_formset_loads_post_attachments( ) attachment_factory(text_file, uploader=user) attachment_factory(text_file, uploader=other_user) + attachment_factory( + text_file, + uploader=user, + post=other_user_private_thread.first_post, + is_deleted=True, + ) formset = get_edit_private_thread_formset(request, private_thread.first_post) assert formset.title @@ -572,6 +581,9 @@ def test_get_edit_thread_post_formset_loads_post_attachments( attachment_factory(text_file, uploader=other_user, post=other_thread.first_post) attachment_factory(text_file, uploader=user) attachment_factory(text_file, uploader=other_user) + attachment_factory( + text_file, uploader=user, post=thread.first_post, is_deleted=True + ) formset = get_edit_thread_post_formset(request, thread.first_post) assert not formset.title @@ -676,6 +688,9 @@ def test_get_edit_private_thread_post_formset_loads_post_attachments( ) attachment_factory(text_file, uploader=user) attachment_factory(text_file, uploader=other_user) + attachment_factory( + text_file, uploader=user, post=private_thread.first_post, is_deleted=True + ) formset = get_edit_private_thread_post_formset(request, private_thread.first_post) assert not formset.title