@@ -105,23 +105,25 @@ async def test_upload_new_files_from_manifest(
105105 )
106106
107107 # WHEN I sync to Synapse
108- await project_model .sync_to_synapse_async (
108+ uploaded_files = await project_model .sync_to_synapse_async (
109109 manifest_path = str (manifest_path ),
110110 send_messages = False ,
111111 synapse_client = self .syn ,
112112 )
113113
114- # THEN both files should exist in Synapse
115- synced = await Project (id = project_model .id ).sync_from_synapse_async (
116- recursive = False , download_file = False , synapse_client = self .syn
117- )
118- names = {f .name for f in synced .files }
119- assert name_a in names
120- assert name_b in names
114+ for f in uploaded_files :
115+ self .schedule_for_cleanup (f .id )
121116
122- for f in synced .files :
123- if f .name in (name_a , name_b ):
124- self .schedule_for_cleanup (f .id )
117+ # THEN both files are returned and exist in Synapse
118+ assert len (uploaded_files ) == 2
119+ uploaded_names = {f .name for f in uploaded_files }
120+ assert name_a in uploaded_names
121+ assert name_b in uploaded_names
122+
123+ for f in uploaded_files :
124+ file_entity = await File (id = f .id ).get_async (synapse_client = self .syn )
125+ assert file_entity .id is not None
126+ assert file_entity .parent_id == project_model .id
125127
126128 async def test_annotations_written_to_synapse (
127129 self , project_model : Project , tmp_path : Path
@@ -145,24 +147,28 @@ async def test_annotations_written_to_synapse(
145147 )
146148
147149 # WHEN I sync to Synapse
148- await project_model .sync_to_synapse_async (
150+ uploaded_files = await project_model .sync_to_synapse_async (
149151 manifest_path = str (manifest_path ),
150152 send_messages = False ,
151153 synapse_client = self .syn ,
152154 )
153155
154- # THEN the file exists with the correct annotations
155- synced = await Project (id = project_model .id ).sync_from_synapse_async (
156- recursive = False , download_file = False , synapse_client = self .syn
157- )
158- uploaded = next ((f for f in synced .files if f .name == unique_name ), None )
159- assert uploaded is not None
160- self .schedule_for_cleanup (uploaded .id )
156+ for f in uploaded_files :
157+ self .schedule_for_cleanup (f .id )
161158
162- refreshed = await File (id = uploaded .id ).get_async (synapse_client = self .syn )
163- assert refreshed .annotations .get ("my_string" ) == ["hello" ]
164- # "42" in the CSV is parsed by ast.literal_eval into the integer 42
165- assert refreshed .annotations .get ("my_number" ) == [42 ]
159+ # THEN the file is returned and exists in Synapse
160+ # AND the file exists with the correct annotations
161+ assert len (uploaded_files ) == 1
162+ uploaded_names = {f .name for f in uploaded_files }
163+ assert unique_name in uploaded_names
164+
165+ for f in uploaded_files :
166+ file_entity = await File (id = f .id ).get_async (synapse_client = self .syn )
167+ assert file_entity .id is not None
168+ assert file_entity .parent_id == project_model .id
169+ assert file_entity .annotations .get ("my_string" ) == ["hello" ]
170+ # "42" in the CSV is parsed by ast.literal_eval into the integer 42
171+ assert file_entity .annotations .get ("my_number" ) == [42 ]
166172
167173 async def test_update_existing_file_creates_new_version (
168174 self , project_model : Project , tmp_path : Path
0 commit comments