4
4
5
5
from databricks .labs .ucx .framework .owners import Ownership
6
6
from databricks .labs .ucx .framework .utils import escape_sql_identifier
7
- from databricks .labs .ucx .hive_metastore .table_migration_status import (
8
- TableMigrationStatusRefresher ,
9
- TableMigrationStatus ,
10
- )
7
+ from databricks .labs .ucx .hive_metastore .table_migration_status import TableMigrationIndex
11
8
from databricks .labs .ucx .hive_metastore .tables import Table
9
+ from databricks .labs .ucx .progress .grants import GrantProgressEncoder
12
10
from databricks .labs .ucx .progress .tables import TableProgressEncoder
13
11
14
12
21
19
def test_table_progress_encoder_no_failures (mock_backend , table : Table ) -> None :
22
20
ownership = create_autospec (Ownership )
23
21
ownership .owner_of .return_value = "user"
24
- migration_status_crawler = create_autospec (TableMigrationStatusRefresher )
25
- migration_status_crawler .snapshot .return_value = (
26
- TableMigrationStatus (table .database , table .name , "main" , "default" , table .name , update_ts = None ),
27
- )
22
+ table_migration_index = create_autospec (TableMigrationIndex )
23
+ table_migration_index .is_migrated .return_value = True
24
+ grant_progress_encoder = create_autospec (GrantProgressEncoder )
28
25
encoder = TableProgressEncoder (
29
- mock_backend , ownership , migration_status_crawler , run_id = 1 , workspace_id = 123456789 , catalog = "test"
26
+ mock_backend , ownership , table_migration_index , run_id = 1 , workspace_id = 123456789 , catalog = "test"
30
27
)
31
28
32
29
encoder .append_inventory_snapshot ([table ])
33
30
34
31
rows = mock_backend .rows_written_for (escape_sql_identifier (encoder .full_name ), "append" )
35
- assert rows , f"No rows written for: { encoder .full_name } "
32
+ assert len ( rows ) > 0 , f"No rows written for: { encoder .full_name } "
36
33
assert len (rows [0 ].failures ) == 0
37
34
ownership .owner_of .assert_called_once ()
38
- migration_status_crawler .snapshot .assert_called_once ()
35
+ table_migration_index .is_migrated .assert_called_with (table .database , table .name )
36
+ grant_progress_encoder .assert_not_called ()
39
37
40
38
41
39
@pytest .mark .parametrize (
@@ -47,12 +45,11 @@ def test_table_progress_encoder_no_failures(mock_backend, table: Table) -> None:
47
45
def test_table_progress_encoder_pending_migration_failure (mock_backend , table : Table ) -> None :
48
46
ownership = create_autospec (Ownership )
49
47
ownership .owner_of .return_value = "user"
50
- migration_status_crawler = create_autospec (TableMigrationStatusRefresher )
51
- migration_status_crawler .snapshot .return_value = (
52
- TableMigrationStatus (table .database , table .name ), # No destination: therefore not yet migrated.
53
- )
48
+ table_migration_index = create_autospec (TableMigrationIndex )
49
+ table_migration_index .is_migrated .return_value = False
50
+ grant_progress_encoder = create_autospec (GrantProgressEncoder )
54
51
encoder = TableProgressEncoder (
55
- mock_backend , ownership , migration_status_crawler , run_id = 1 , workspace_id = 123456789 , catalog = "test"
52
+ mock_backend , ownership , table_migration_index , run_id = 1 , workspace_id = 123456789 , catalog = "test"
56
53
)
57
54
58
55
encoder .append_inventory_snapshot ([table ])
@@ -61,4 +58,5 @@ def test_table_progress_encoder_pending_migration_failure(mock_backend, table: T
61
58
assert len (rows ) > 0 , f"No rows written for: { encoder .full_name } "
62
59
assert rows [0 ].failures == ["Pending migration" ]
63
60
ownership .owner_of .assert_called_once ()
64
- migration_status_crawler .snapshot .assert_called_once ()
61
+ table_migration_index .is_migrated .assert_called_with (table .database , table .name )
62
+ grant_progress_encoder .assert_not_called ()
0 commit comments