@@ -193,52 +193,58 @@ async def test_import_csv_to_grid_session_async(
193193
194194 # GIVEN: Create a grid session first
195195 grid = Grid (record_set_id = record_set_fixture .id )
196- created_grid = await grid .create_async (
197- timeout = ASYNC_JOB_TIMEOUT_SEC , synapse_client = self .syn
198- )
199-
200- assert created_grid .session_id is not None
196+ try :
197+ created_grid = await grid .create_async (
198+ timeout = ASYNC_JOB_TIMEOUT_SEC , synapse_client = self .syn
199+ )
201200
202- # AND a CSV file uploaded to Synapse
203- test_data = pd .DataFrame (
204- {
205- "id" : [6 , 7 , 8 , 9 , 10 ],
206- "name" : ["Alpha" , "Beta" , "Gamma" , "Delta" , "Epsilon" ],
207- "value" : [10.5 , 20.3 , 30.7 , 40.1 , 50.9 ],
208- "category" : ["A" , "B" , "A" , "C" , "B" ],
209- "active" : [True , False , False , True , True ],
210- }
211- )
201+ assert created_grid .session_id is not None
202+
203+ # AND a CSV file uploaded to Synapse
204+ test_data = pd .DataFrame (
205+ {
206+ "id" : [6 , 7 , 8 , 9 , 10 ],
207+ "name" : ["Alpha" , "Beta" , "Gamma" , "Delta" , "Epsilon" ],
208+ "value" : [10.5 , 20.3 , 30.7 , 40.1 , 50.9 ],
209+ "category" : ["A" , "B" , "A" , "C" , "B" ],
210+ "active" : [True , False , False , True , True ],
211+ }
212+ )
212213
213- # Create a temporary CSV file
214- with tempfile .NamedTemporaryFile ("w" , suffix = ".csv" , delete = False ) as temp_csv :
215- test_data .to_csv (temp_csv .name , index = False )
216- self .schedule_for_cleanup (temp_csv .name )
214+ # Create a temporary CSV file
215+ with tempfile .NamedTemporaryFile (
216+ "w" , suffix = ".csv" , delete = False
217+ ) as temp_csv :
218+ test_data .to_csv (temp_csv .name , index = False )
219+ self .schedule_for_cleanup (temp_csv .name )
217220
218- file = await File (
219- path = temp_csv .name , parent_id = project_model .id
220- ).store_async (synapse_client = self .syn )
221+ file = await File (
222+ path = temp_csv .name , parent_id = project_model .id
223+ ).store_async (synapse_client = self .syn )
221224
222- self .schedule_for_cleanup (file .id )
225+ self .schedule_for_cleanup (file .id )
223226
224- # WHEN: Importing the CSV into the grid session
225- imported_grid = await created_grid .import_csv_async (
226- file_handle_id = file .file_handle .id ,
227- timeout = ASYNC_JOB_TIMEOUT_SEC ,
228- synapse_client = self .syn ,
229- )
227+ # WHEN: Importing the CSV into the grid session
228+ imported_grid = await created_grid .import_csv_async (
229+ file_handle_id = file .file_handle .id ,
230+ timeout = ASYNC_JOB_TIMEOUT_SEC ,
231+ synapse_client = self .syn ,
232+ )
230233
231- # THEN: The import should complete and return the Grid with the same session
232- assert imported_grid .session_id == created_grid .session_id
234+ # THEN: The import should complete and return the Grid with the same session
235+ assert imported_grid .session_id == created_grid .session_id
233236
234- # WHEN: Exporting the grid back to the record set
235- exported_grid = await imported_grid .export_to_record_set_async (
236- timeout = ASYNC_JOB_TIMEOUT_SEC , synapse_client = self .syn
237- )
237+ # WHEN: Exporting the grid back to the record set
238+ exported_grid = await imported_grid .export_to_record_set_async (
239+ timeout = ASYNC_JOB_TIMEOUT_SEC , synapse_client = self .syn
240+ )
238241
239- # THEN: The export should contain 10 total rows
240- # (5 from the original record set + 5 imported)
241- assert exported_grid .validation_summary_statistics is not None
242- assert (
243- exported_grid .validation_summary_statistics .total_number_of_children == 10
244- )
242+ # THEN: The export should contain 10 total rows
243+ # (5 from the original record set + 5 imported)
244+ assert exported_grid .validation_summary_statistics is not None
245+ assert (
246+ exported_grid .validation_summary_statistics .total_number_of_children
247+ == 10
248+ )
249+ finally :
250+ await created_grid .delete_async (synapse_client = self .syn )
0 commit comments