[SYNPY-1870] Rewrite test_caching.py to not use deprecated legacy code#1425
Merged
Conversation
andrewelamb
marked this pull request as draft
July 15, 2026 15:31
andrewelamb
marked this pull request as ready for review
July 15, 2026 15:39
linglp
approved these changes
Jul 17, 2026
linglp
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Just some minor comments.
BryanFauble
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
The integration test
tests/integration/synapseclient/core/test_caching.pywas written against the legacy pre-OOP API and emitted a large number ofDeprecationWarnings (all slated for removal in 5.0.0) on every run. Running the test produced warnings for the legacyProject/File/Entityclasses,Synapse.store,Synapse.get,Synapse.getChildren, and — indirectly, through the store path —Synapse.findEntityId, along with the internal legacy machinery those calls fanned out to (_getEntityBundle,_check_entity_restrictions,_getWithEntityBundle_async,Annotations/set_annotations,download_file_entity).While migrating the test off the deprecated public API, the
findEntityIdwarning turned out to originate in production code, not the test:synapseclient/models/services/search.py::get_id()(used by every modelstore/getfor name+parent resolution) still called the deprecatedSynapse.findEntityIdvia anasyncioexecutor shim, carrying a# TODO: SYNPY-1623marker. So the OOP models themselves were still routing through a deprecated method.Solution:
Migrated the test to the object-oriented models and operations layer, and fixed the underlying production code path so the models no longer depend on a deprecated method.
tests/integration/synapseclient/core/test_caching.py:Project/Filenow come fromsynapseclient.modelsinstead of the legacy root classes.syn.store(...)/syn.get(...)replaced with the model methodsentity.store(synapse_client=syn)/entity.get(synapse_client=syn)(andFile(id=id).get(...)for fetch-by-id).syn.getChildren(...)replaced withsynapseclient.api.get_childrendriven throughwrap_async_generator_to_sync_generator(the same sync-consumption helper theStorableContainermixin uses), since the workers run in sync executor threads. This preserves the lightweight "list child IDs" behavior rather than switching to the heaviersync_from_synapse(which would download files and change what the test exercises).synapseclient/models/services/search.py:get_id()now callsfind_entity_id_async(per the deprecation guidance,from synapseclient.operations import find_entity_id), replacing the deprecatedfindEntityId+run_in_executorshim. The async variant is used becauseget_idis a coroutine; it is imported lazily to avoid anoperations → models → searchcircular import (mirroring howfind_entity_id_asyncitself lazily importsapi.get_child).import asyncioand the SYNPY-1623 TODO, and updated the docstring reference. Behavior is equivalent:find_entity_id_asyncresolves the parent viaid_of()and callsapi.get_child, which supportsparentId=Nonefor the Project-by-name lookup — matching the oldfindEntityId(name, parent)contract.This resolves the SYNPY-1623 tech debt as a side effect.
get_id()has callers acrossproject,folder,file,link,recordset, andtable_components; the signature and return contract are unchanged, so all callers are unaffected.Testing:
unit_test_project_async.py/unit_test_folder_async.pyfailed withpytest_socket.SocketBlockedErrorbecause they mockedSynapse.findEntityId, whichget_idno longer calls (the realget_childattempted a network call).patch("synapseclient.operations.find_entity_id_async", new_callable=AsyncMock, ...)) and to includesynapse_client=self.synin the correspondingassert_called_once_withassertions.tests/unit/synapseclient/models/andtests/unit/synapseclient/operations/.DeprecationWarningpromoted to an error raises nothing, and confirmed no circular import from the lazyfind_entity_id_asyncimport.