From 01997d3b1b6c3ec4bf352537b2f1fa0d7ad71008 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Fri, 24 Apr 2026 15:03:54 -0400 Subject: [PATCH 1/5] correct way of cleaning up wiki --- .../models/async/test_wiki_async.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_wiki_async.py b/tests/integration/synapseclient/models/async/test_wiki_async.py index 971be086e..c51ccebe1 100644 --- a/tests/integration/synapseclient/models/async/test_wiki_async.py +++ b/tests/integration/synapseclient/models/async/test_wiki_async.py @@ -61,7 +61,7 @@ async def test_get_wiki_page_by_id( retrieved_wiki = await WikiPage( owner_id=root_wiki.owner_id, id=root_wiki.id ).get_async(synapse_client=self.syn) - schedule_for_cleanup(retrieved_wiki.id) + schedule_for_cleanup(retrieved_wiki) # THEN the retrieved wiki should match the created one assert retrieved_wiki.id == root_wiki.id @@ -81,7 +81,7 @@ async def test_get_wiki_page_by_title( retrieved_wiki = await WikiPage( owner_id=root_wiki.owner_id, title=root_wiki.title ).get_async(synapse_client=self.syn) - schedule_for_cleanup(retrieved_wiki.id) + schedule_for_cleanup(retrieved_wiki) # THEN the retrieved wiki should match the created one assert retrieved_wiki.id == root_wiki.id assert retrieved_wiki.title == root_wiki.title @@ -102,7 +102,7 @@ async def test_delete_wiki_page( title=f"Wiki Page to be deleted {str(uuid.uuid4())}", markdown="# Wiki Page to be deleted\n\nThis is a wiki page to be deleted.", ).store_async(synapse_client=self.syn) - schedule_for_cleanup(wiki_page_to_delete.id) + schedule_for_cleanup(wiki_page_to_delete) # WHEN deleting the wiki page await wiki_page_to_delete.delete_async(synapse_client=self.syn) @@ -129,7 +129,7 @@ async def test_create_sub_wiki_page( title=title, markdown="# Sub Wiki Basic Operations\n\nThis is a sub wiki basic operations page.", ).store_async(synapse_client=self.syn) - schedule_for_cleanup(sub_wiki.id) + schedule_for_cleanup(sub_wiki) # THEN the sub-wiki page should be created assert sub_wiki.id is not None assert sub_wiki.title == title @@ -185,7 +185,7 @@ async def wiki_page_with_attachment( attachments=[filename], ) wiki_page = await wiki_page.store_async(synapse_client=syn) - schedule_for_cleanup(wiki_page.id) + schedule_for_cleanup(wiki_page) attachment_name = os.path.basename(filename) return wiki_page, attachment_name @@ -337,7 +337,7 @@ async def test_download_attachment_large_file( attachments=[filename], ) wiki_page = await wiki_page.store_async(synapse_client=self.syn) - schedule_for_cleanup(wiki_page.id) + schedule_for_cleanup(wiki_page) # WHEN downloading the attachment downloaded_path = await wiki_page.get_attachment_async( file_name=os.path.basename(filename), @@ -378,7 +378,7 @@ async def wiki_page_with_gz_attachment( attachments=[gz_filename], ) sub_wiki = await wiki_page.store_async(synapse_client=syn) - schedule_for_cleanup(sub_wiki.id) + schedule_for_cleanup(sub_wiki) attachment_name = os.path.basename(gz_filename) return sub_wiki, attachment_name @@ -553,7 +553,7 @@ async def wiki_page_with_markdown( parent_id=root_wiki.id, ) sub_wiki = await wiki_page.store_async(synapse_client=syn) - schedule_for_cleanup(sub_wiki.id) + schedule_for_cleanup(sub_wiki) return sub_wiki async def test_get_markdown_url( @@ -622,7 +622,7 @@ async def wiki_page_with_markdown_gz( parent_id=root_wiki.id, ) sub_wiki = await wiki_page.store_async(synapse_client=syn) - schedule_for_cleanup(sub_wiki.id) + schedule_for_cleanup(sub_wiki) return sub_wiki async def test_get_markdown_url_gz_file( @@ -718,7 +718,7 @@ async def wiki_page_with_multiple_versions( updated_wiki = await WikiPage( owner_id=root_wiki.owner_id, id=updated_wiki.id, title="Version 2" ).store_async(synapse_client=syn) - schedule_for_cleanup(updated_wiki.id) + schedule_for_cleanup(updated_wiki) return updated_wiki async def test_wiki_page_history( From bf4f4a979b9216efb8a55ea808609d358a9468e7 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Fri, 24 Apr 2026 15:13:50 -0400 Subject: [PATCH 2/5] clean up is not needed after make_bogus_uuid_file() --- .../models/async/test_wiki_async.py | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_wiki_async.py b/tests/integration/synapseclient/models/async/test_wiki_async.py index c51ccebe1..c257fe00e 100644 --- a/tests/integration/synapseclient/models/async/test_wiki_async.py +++ b/tests/integration/synapseclient/models/async/test_wiki_async.py @@ -173,7 +173,6 @@ async def wiki_page_with_attachment( """Create a wiki page with an attachment.""" # Create a temporary file for attachment filename = utils.make_bogus_uuid_file() - schedule_for_cleanup(filename) # GIVEN a root wiki page root_wiki = wiki_page_fixture # Create wiki page with attachment @@ -192,10 +191,9 @@ async def wiki_page_with_attachment( async def test_get_attachment_handles( self, wiki_page_with_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with an attachment - wiki_page, attachment_name = wiki_page_with_attachment + wiki_page, _ = wiki_page_with_attachment # WHEN getting attachment handles attachment_handles = await wiki_page.get_attachment_handles_async( @@ -204,12 +202,10 @@ async def test_get_attachment_handles( # THEN attachment handles should be returned assert len(attachment_handles["list"]) > 0 - schedule_for_cleanup(attachment_handles) async def test_get_attachment_url( self, wiki_page_with_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with an attachment wiki_page, attachment_name = wiki_page_with_attachment @@ -221,12 +217,10 @@ async def test_get_attachment_url( # THEN a URL should be returned assert len(attachment_url) > 0 - schedule_for_cleanup(attachment_url) async def test_download_attachment( self, wiki_page_with_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with an attachment wiki_page, attachment_name = wiki_page_with_attachment @@ -242,14 +236,12 @@ async def test_download_attachment( download_location=download_dir, synapse_client=self.syn, ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded assert os.path.exists(downloaded_path) async def test_get_attachment_preview_url( self, wiki_page_with_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with an attachment wiki_page, attachment_name = wiki_page_with_attachment @@ -268,19 +260,16 @@ async def test_get_attachment_preview_url( # THEN a URL should be returned assert len(preview_url) > 0 - schedule_for_cleanup(preview_url) async def test_download_attachment_preview( self, wiki_page_with_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with an attachment wiki_page, attachment_name = wiki_page_with_attachment # AND a download location download_dir = tempfile.mkdtemp() - self.schedule_for_cleanup(download_dir) # Poll until attachment preview is available for download await wait_for_condition( @@ -301,7 +290,6 @@ async def test_download_attachment_preview( download_location=download_dir, synapse_client=self.syn, ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded assert os.path.exists(downloaded_path) assert os.path.basename(downloaded_path) == "preview.txt" @@ -312,7 +300,6 @@ async def test_download_attachment_preview( ) async def test_download_attachment_large_file( self, - syn: Synapse, schedule_for_cleanup: Callable[..., None], wiki_page_fixture: WikiPage, ) -> None: @@ -326,7 +313,6 @@ async def test_download_attachment_large_file( # AND a download location download_dir = tempfile.mkdtemp() - schedule_for_cleanup(download_dir) # Create wiki page with attachment wiki_page = WikiPage( @@ -345,7 +331,6 @@ async def test_download_attachment_large_file( download_location=download_dir, synapse_client=self.syn, ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded assert os.path.exists(downloaded_path) assert os.path.basename(downloaded_path) == os.path.basename(filename) @@ -365,7 +350,6 @@ async def wiki_page_with_gz_attachment( os.rename(filename, gz_filename) with gzip.open(gz_filename, "wt") as f: f.write("hello world\n") - schedule_for_cleanup(gz_filename) # GIVEN a root wiki page root_wiki = wiki_page_fixture @@ -385,11 +369,10 @@ async def wiki_page_with_gz_attachment( async def test_get_attachment_handles_gz_file( self, wiki_page_with_gz_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: """Test getting attachment handles for a gz file.""" # GIVEN a wiki page with a gz attachment - wiki_page, attachment_name = wiki_page_with_gz_attachment + wiki_page, _ = wiki_page_with_gz_attachment # WHEN getting attachment handles attachment_handles = await wiki_page.get_attachment_handles_async( synapse_client=self.syn @@ -402,12 +385,10 @@ async def test_get_attachment_handles_gz_file( handle.get("fileName", "").endswith(".gz") for handle in attachment_handles["list"] ) - schedule_for_cleanup(attachment_handles) async def test_get_attachment_url_gz_file( self, wiki_page_with_gz_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: """Test getting attachment URL for a gz file.""" # GIVEN a wiki page with a gz attachment @@ -419,12 +400,10 @@ async def test_get_attachment_url_gz_file( ) # THEN a URL should be returned assert len(attachment_url) > 0 - schedule_for_cleanup(attachment_url) async def test_download_attachment_gz_file( self, wiki_page_with_gz_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: """Test downloading a gz attachment file.""" # GIVEN a wiki page with a gz attachment @@ -432,7 +411,6 @@ async def test_download_attachment_gz_file( # AND a download location download_dir = tempfile.mkdtemp() - schedule_for_cleanup(download_dir) # WHEN downloading the gz attachment downloaded_path = await wiki_page.get_attachment_async( @@ -441,7 +419,6 @@ async def test_download_attachment_gz_file( download_location=download_dir, synapse_client=self.syn, ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded assert os.path.exists(downloaded_path) @@ -450,7 +427,6 @@ async def test_download_attachment_gz_file( async def test_get_attachment_preview_url_gz_file( self, wiki_page_with_gz_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: """Test getting attachment preview URL for a gz file.""" # GIVEN a wiki page with a gz attachment @@ -470,12 +446,10 @@ async def test_get_attachment_preview_url_gz_file( # THEN a URL should be returned assert len(preview_url) > 0 - schedule_for_cleanup(preview_url) async def test_download_attachment_preview_gz_file( self, wiki_page_with_gz_attachment: tuple[WikiPage, str], - schedule_for_cleanup: Callable[..., None], ) -> None: """Test downloading attachment preview for a gz file.""" # GIVEN a wiki page with a gz attachment @@ -495,7 +469,6 @@ async def test_download_attachment_preview_gz_file( # AND a download location download_dir = tempfile.mkdtemp() - self.schedule_for_cleanup(download_dir) # WHEN downloading the attachment preview downloaded_path = await wiki_page.get_attachment_preview_async( @@ -504,7 +477,6 @@ async def test_download_attachment_preview_gz_file( download_location=download_dir, synapse_client=self.syn, ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded assert os.path.exists(downloaded_path) From 490761cc11b98d547fb0c5cbed285c6bac9f7614 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Fri, 24 Apr 2026 15:17:14 -0400 Subject: [PATCH 3/5] clean up TestWikiPageMarkdown clean up --- .../synapseclient/models/async/test_wiki_async.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_wiki_async.py b/tests/integration/synapseclient/models/async/test_wiki_async.py index c257fe00e..861dfac2d 100644 --- a/tests/integration/synapseclient/models/async/test_wiki_async.py +++ b/tests/integration/synapseclient/models/async/test_wiki_async.py @@ -531,7 +531,6 @@ async def wiki_page_with_markdown( async def test_get_markdown_url( self, wiki_page_with_markdown: WikiPage, - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with markdown root_wiki = wiki_page_with_markdown @@ -540,14 +539,12 @@ async def test_get_markdown_url( markdown_url = await WikiPage( owner_id=root_wiki.owner_id, id=root_wiki.id ).get_markdown_file_async(download_file=False, synapse_client=self.syn) - schedule_for_cleanup(markdown_url) # THEN a URL should be returned assert len(markdown_url) > 0 async def test_download_markdown_file( self, wiki_page_with_markdown: WikiPage, - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with markdown root_wiki = wiki_page_with_markdown @@ -567,7 +564,6 @@ async def test_download_markdown_file( with open(downloaded_path, "r", encoding="utf-8") as f: content = f.read() assert "Sub Wiki Markdown" in content - schedule_for_cleanup(download_dir) @pytest.fixture(scope="function") async def wiki_page_with_markdown_gz( @@ -584,7 +580,6 @@ async def wiki_page_with_markdown_gz( os.rename(filename, md_gz_filename) with gzip.open(md_gz_filename, "wt") as f: f.write("# Test Wiki\n\nThis is test content.") - schedule_for_cleanup(md_gz_filename) # Create wiki page with markdown gz wiki_page = WikiPage( @@ -600,7 +595,6 @@ async def wiki_page_with_markdown_gz( async def test_get_markdown_url_gz_file( self, wiki_page_with_markdown_gz: WikiPage, - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with markdown gz root_wiki = wiki_page_with_markdown_gz @@ -609,14 +603,12 @@ async def test_get_markdown_url_gz_file( markdown_url = await WikiPage( owner_id=root_wiki.owner_id, id=root_wiki.id ).get_markdown_file_async(download_file=False, synapse_client=self.syn) - schedule_for_cleanup(markdown_url) # THEN a URL should be returned assert len(markdown_url) > 0 async def test_download_markdown_file_gz_file( self, wiki_page_with_markdown_gz: WikiPage, - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with markdown gz root_wiki = wiki_page_with_markdown_gz @@ -630,14 +622,12 @@ async def test_download_markdown_file_gz_file( ).get_markdown_file_async( download_file=True, download_location=download_dir, synapse_client=self.syn ) - schedule_for_cleanup(downloaded_path) # THEN the file should be downloaded and unzipped assert os.path.exists(downloaded_path) # Verify content with open(downloaded_path, "r", encoding="utf-8") as f: content = f.read() assert "Test Wiki" in content - schedule_for_cleanup(download_dir) class TestWikiPageVersioning: From 7eb8d9745ff1ca7bc913f29520e227782b1fdee5 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Fri, 24 Apr 2026 15:20:51 -0400 Subject: [PATCH 4/5] history cannot be cleaned up --- tests/integration/synapseclient/models/async/test_wiki_async.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_wiki_async.py b/tests/integration/synapseclient/models/async/test_wiki_async.py index 861dfac2d..c4c2390ee 100644 --- a/tests/integration/synapseclient/models/async/test_wiki_async.py +++ b/tests/integration/synapseclient/models/async/test_wiki_async.py @@ -686,7 +686,6 @@ async def wiki_page_with_multiple_versions( async def test_wiki_page_history( self, wiki_page_with_multiple_versions, - schedule_for_cleanup: Callable[..., None], ) -> None: # GIVEN a wiki page with multiple versions sub_wiki = wiki_page_with_multiple_versions @@ -698,7 +697,6 @@ async def test_wiki_page_history( history.append(item) # THEN history should be returned assert len(history) == 3 - schedule_for_cleanup(history) async def test_restore_wiki_page_version( self, From 3527aa6d5dfd875cd4f5b2c8a33e871c9457fcf1 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Fri, 24 Apr 2026 15:26:35 -0400 Subject: [PATCH 5/5] remove cleanup that do not work --- .../models/async/test_wiki_async.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_wiki_async.py b/tests/integration/synapseclient/models/async/test_wiki_async.py index c4c2390ee..c93996e6a 100644 --- a/tests/integration/synapseclient/models/async/test_wiki_async.py +++ b/tests/integration/synapseclient/models/async/test_wiki_async.py @@ -746,7 +746,8 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None: self.schedule_for_cleanup = schedule_for_cleanup async def test_get_wiki_header_tree( - self, wiki_page_fixture: WikiPage, schedule_for_cleanup: Callable[..., None] + self, + wiki_page_fixture: WikiPage, ) -> None: await asyncio.sleep(5) # WHEN getting the wiki header tree @@ -758,7 +759,6 @@ async def test_get_wiki_header_tree( # THEN headers should be returned assert len(headers) >= 1 - schedule_for_cleanup(headers) class TestWikiOrderHint: @@ -804,7 +804,8 @@ async def test_get_wiki_order_hint( schedule_for_cleanup(order_hint) async def test_store_wiki_order_hint( - self, wiki_page_fixture: WikiPage, schedule_for_cleanup: Callable[..., None] + self, + wiki_page_fixture: WikiPage, ) -> None: await asyncio.sleep(5) # Get headers @@ -819,23 +820,14 @@ async def test_store_wiki_order_hint( order_hint = await WikiOrderHint(owner_id=wiki_page_fixture.owner_id).get_async( synapse_client=self.syn ) - schedule_for_cleanup(order_hint) # WHEN setting a custom order order_hint.id_list = header_ids updated_order_hint = await order_hint.store_async(synapse_client=self.syn) - schedule_for_cleanup(updated_order_hint) await asyncio.sleep(5) # THEN the order hint should be updated # Retrieve the updated order hint retrieved_order_hint = await WikiOrderHint( owner_id=wiki_page_fixture.owner_id ).get_async(synapse_client=self.syn) - schedule_for_cleanup(retrieved_order_hint) assert retrieved_order_hint.id_list == header_ids assert len(retrieved_order_hint.id_list) >= 1 - - # clean up the wiki pages for other tests in the same session - async def test_cleanup_wiki_pages(self, wiki_page_fixture: WikiPage): - root_wiki = wiki_page_fixture - await root_wiki.delete_async(synapse_client=self.syn) - assert True