@@ -61,77 +61,3 @@ def test_duck_db_cache_config_get_database_name_with_default_schema_name():
6161
6262def test_duck_db_cache_config_inheritance_from_sql_cache_config_base ():
6363 assert issubclass (DuckDBCache , CacheBase )
64-
65-
66- def test_create_source_tables (mocker ):
67- """Test that the create_source_tables method correctly creates tables based on the source's catalog."""
68- # Import here to avoid circular imports
69- from airbyte_protocol .models import (
70- ConfiguredAirbyteCatalog ,
71- ConfiguredAirbyteStream ,
72- )
73-
74- # Create a proper ConfiguredAirbyteCatalog for mocking
75- stream1 = ConfiguredAirbyteStream (
76- stream = {
77- "name" : "stream1" ,
78- "json_schema" : {},
79- "supported_sync_modes" : ["full_refresh" ],
80- },
81- sync_mode = "full_refresh" ,
82- destination_sync_mode = "overwrite" ,
83- )
84- stream2 = ConfiguredAirbyteStream (
85- stream = {
86- "name" : "stream2" ,
87- "json_schema" : {},
88- "supported_sync_modes" : ["full_refresh" ],
89- },
90- sync_mode = "full_refresh" ,
91- destination_sync_mode = "overwrite" ,
92- )
93- catalog = ConfiguredAirbyteCatalog (streams = [stream1 , stream2 ])
94-
95- # Mock the catalog provider
96- mock_catalog_provider = mocker .Mock ()
97- mock_catalog_provider .stream_names = ["stream1" , "stream2" ]
98- mocker .patch (
99- "airbyte.shared.catalog_providers.CatalogProvider" ,
100- return_value = mock_catalog_provider ,
101- )
102-
103- # Mock a source with configured catalog and selected streams
104- mock_source = mocker .Mock ()
105- mock_source .get_configured_catalog .return_value = catalog
106- mock_source .get_selected_streams .return_value = ["stream1" ]
107-
108- # Create a DuckDBCache instance with mocked processor
109- cache = DuckDBCache (db_path = UNIT_TEST_DB_PATH )
110-
111- # Mock the processor property
112- mock_processor = mocker .Mock ()
113- mocker .patch .object (
114- DuckDBCache , "processor" , mocker .PropertyMock (return_value = mock_processor )
115- )
116-
117- # Test with default (None) stream parameter - should use source's selected streams
118- cache .create_source_tables (mock_source )
119-
120- # Verify the correct methods were called
121- mock_source .get_selected_streams .assert_called_once ()
122- mock_source .get_configured_catalog .assert_called_once_with (streams = ["stream1" ])
123- mock_processor ._ensure_schema_exists .assert_called_once ()
124- assert mock_processor ._ensure_final_table_exists .call_count == 2
125-
126- # Reset mocks
127- mock_source .reset_mock ()
128- mock_processor .reset_mock ()
129-
130- # Test with explicit stream list
131- cache .create_source_tables (mock_source , streams = ["stream2" ])
132-
133- # Verify the correct methods were called
134- mock_source .get_selected_streams .assert_not_called ()
135- mock_source .get_configured_catalog .assert_called_once_with (streams = ["stream2" ])
136- mock_processor ._ensure_schema_exists .assert_called_once ()
137- assert mock_processor ._ensure_final_table_exists .call_count == 2
0 commit comments