@@ -718,30 +718,52 @@ def test_assign_metastore(acc_client, caplog):
718718 assign_metastore (acc_client , "123" )
719719
720720
721- def test_migrate_tables (ws ):
722- ws .jobs .wait_get_run_job_terminated_or_skipped .return_value = Run (
723- state = RunState (result_state = RunResultState .SUCCESS ), start_time = 0 , end_time = 1000 , run_duration = 1000
721+ @pytest .mark .parametrize ("run_as_collection" , [False , True ])
722+ def test_migrate_tables_calls_migrate_table_job_run_now (
723+ run_as_collection ,
724+ workspace_clients ,
725+ acc_client ,
726+ ) -> None :
727+ if not run_as_collection :
728+ workspace_clients = [workspace_clients [0 ]]
729+ run = Run (
730+ state = RunState (result_state = RunResultState .SUCCESS ),
731+ start_time = 0 ,
732+ end_time = 1000 ,
733+ run_duration = 1000 ,
724734 )
725- prompts = MockPrompts ({})
726- migrate_tables (ws , prompts )
727- ws .jobs .run_now .assert_called_with (456 )
728- ws .jobs .wait_get_run_job_terminated_or_skipped .assert_called_once ()
735+ for workspace_client in workspace_clients :
736+ workspace_client .jobs .wait_get_run_job_terminated_or_skipped .return_value = run
737+
738+ migrate_tables (workspace_clients [0 ], MockPrompts ({}), run_as_collection = run_as_collection , a = acc_client )
739+
740+ for workspace_client in workspace_clients :
741+ workspace_client .jobs .run_now .assert_called_with (456 )
742+ workspace_client .jobs .wait_get_run_job_terminated_or_skipped .assert_called_once ()
729743
730744
731- def test_migrate_external_hiveserde_tables_in_place (ws ):
745+ def test_migrate_tables_calls_external_hiveserde_tables_job_run_now (ws ) -> None :
746+ # TODO: Test for running on a collection when context injection for multiple workspaces is supported.
732747 tables_crawler = create_autospec (TablesCrawler )
733748 table = Table (
734- catalog = "hive_metastore" , database = "test" , name = "hiveserde" , object_type = "UNKNOWN" , table_format = "HIVE"
749+ catalog = "hive_metastore" ,
750+ database = "test" ,
751+ name = "hiveserde" ,
752+ object_type = "UNKNOWN" ,
753+ table_format = "HIVE" ,
735754 )
736755 tables_crawler .snapshot .return_value = [table ]
737756 ctx = WorkspaceContext (ws ).replace (tables_crawler = tables_crawler )
738757 ws .jobs .wait_get_run_job_terminated_or_skipped .return_value = Run (
739- state = RunState (result_state = RunResultState .SUCCESS ), start_time = 0 , end_time = 1000 , run_duration = 1000
758+ state = RunState (result_state = RunResultState .SUCCESS ),
759+ start_time = 0 ,
760+ end_time = 1000 ,
761+ run_duration = 1000 ,
740762 )
741763
742764 prompt = (
743- "Found 1 (.*) hiveserde tables, do you want to run the "
744- "migrate-external-hiveserde-tables-in-place-experimental workflow?"
765+ "Found 1 (.*) hiveserde tables in https://localhost , do you want to run the "
766+ "` migrate-external-hiveserde-tables-in-place-experimental` workflow?"
745767 )
746768 prompts = MockPrompts ({prompt : "Yes" })
747769
@@ -751,20 +773,28 @@ def test_migrate_external_hiveserde_tables_in_place(ws):
751773 ws .jobs .wait_get_run_job_terminated_or_skipped .call_count = 2
752774
753775
754- def test_migrate_external_tables_ctas (ws ):
776+ def test_migrate_tables_calls_external_tables_ctas_job_run_now (ws ) -> None :
777+ # TODO: Test for running on a collection when context injection for multiple workspaces is supported.
755778 tables_crawler = create_autospec (TablesCrawler )
756779 table = Table (
757- catalog = "hive_metastore" , database = "test" , name = "externalctas" , object_type = "UNKNOWN" , table_format = "EXTERNAL"
780+ catalog = "hive_metastore" ,
781+ database = "test" ,
782+ name = "externalctas" ,
783+ object_type = "UNKNOWN" ,
784+ table_format = "EXTERNAL" ,
758785 )
759786 tables_crawler .snapshot .return_value = [table ]
760787 ctx = WorkspaceContext (ws ).replace (tables_crawler = tables_crawler )
761788 ws .jobs .wait_get_run_job_terminated_or_skipped .return_value = Run (
762- state = RunState (result_state = RunResultState .SUCCESS ), start_time = 0 , end_time = 1000 , run_duration = 1000
789+ state = RunState (result_state = RunResultState .SUCCESS ),
790+ start_time = 0 ,
791+ end_time = 1000 ,
792+ run_duration = 1000 ,
763793 )
764794
765795 prompt = (
766- "Found 1 (.*) external tables which cannot be migrated using sync, do you want to run the "
767- "migrate-external-tables-ctas workflow?"
796+ "Found 1 (.*) external tables which cannot be migrated using sync in https://localhost , do you want to run the "
797+ "` migrate-external-tables-ctas` workflow?"
768798 )
769799
770800 prompts = MockPrompts ({prompt : "Yes" })
0 commit comments