@@ -27,14 +27,18 @@ def test_table_migration_job_refreshes_migration_status(ws, installation_ctx, pr
2727 ctx .workspace_installation .run ()
2828 ctx .deployed_workflows .run_workflow (workflow )
2929
30+ # Avoiding MigrationStatusRefresh as it will refresh the status before fetching
31+ migration_status_query = f"SELECT * FROM { ctx .config .inventory_database } .migration_status"
32+ migration_statuses = list (ctx .sql_backend .fetch (migration_status_query ))
33+
34+ assert len (migration_statuses ) > 0 , "No migration statuses found"
35+
3036 asserts = []
3137 for table in tables .values ():
32- # Avoiding MigrationStatusRefresh as it will refresh the status before fetching
33- query_migration_status = (
34- f"SELECT * FROM { ctx .config .inventory_database } .migration_status "
35- f"WHERE src_schema = '{ table .schema_name } ' AND src_table = '{ table .name } '"
36- )
37- migration_status = list (ctx .sql_backend .fetch (query_migration_status ))
38+ migration_status = []
39+ for status in migration_statuses :
40+ if status .src_schema == table .schema_name and status .src_table == table .name :
41+ migration_status .append (status )
3842
3943 assert_message_postfix = f" found for { table .table_type } { table .full_name } "
4044 if len (migration_status ) == 0 :
@@ -46,4 +50,7 @@ def test_table_migration_job_refreshes_migration_status(ws, installation_ctx, pr
4650 elif migration_status [0 ].dst_table is None :
4751 asserts .append ("No destination table" + assert_message_postfix )
4852
49- assert len (asserts ) == 0 , "\n " .join (asserts )
53+ assert_message = (
54+ "\n " .join (asserts ) + " given migration statuses " + "\n " .join ([str (status ) for status in migration_statuses ])
55+ )
56+ assert len (asserts ) == 0 , assert_message
0 commit comments