def test_find_datasource_with_asset_on_context_with_no_datasources( empty_data_context, ): context = empty_data_context assert len(context.list_datasources()) == 0 renderer = CheckpointNewNotebookRenderer(context, "foo") obs = renderer._find_datasource_with_asset() assert obs is None
def test_find_datasource_with_asset_on_happy_path_context( deterministic_asset_dataconnector_context, ): context = deterministic_asset_dataconnector_context assert len(context.list_datasources()) == 1 renderer = CheckpointNewNotebookRenderer(context, "foo") obs = renderer._find_datasource_with_asset() assert obs == { "asset_name": "users", "data_connector_name": "my_other_data_connector", "datasource_name": "my_datasource", }
def test_find_datasource_with_asset_on_context_with_a_datasource_with_a_dataconnector_that_has_no_assets( assetless_dataconnector_context, ): context = assetless_dataconnector_context assert list(context.get_datasource("my_datasource").data_connectors.keys()) == [ "my_other_data_connector" ] # remove data asset name config = context.get_config_with_variables_substituted() root_directory = context.root_directory context = BaseDataContext(project_config=config, context_root_dir=root_directory) renderer = CheckpointNewNotebookRenderer(context, "foo") obs = renderer._find_datasource_with_asset() assert obs is None
def test_find_datasource_with_asset_on_context_with_a_datasource_with_no_dataconnectors( titanic_pandas_data_context_with_v013_datasource_stats_enabled_with_checkpoints_v1_with_templates, ): context = titanic_pandas_data_context_with_v013_datasource_stats_enabled_with_checkpoints_v1_with_templates context.delete_datasource("my_datasource") assert len(context.list_datasources()) == 0 context.add_datasource( "aaa_datasource", class_name="Datasource", module_name="great_expectations.datasource.new_datasource", execution_engine={ "class_name": "PandasExecutionEngine", "module_name": "great_expectations.execution_engine", }, ) assert len(context.list_datasources()) == 1 renderer = CheckpointNewNotebookRenderer(context, "foo") obs = renderer._find_datasource_with_asset() assert obs is None
def test_find_datasource_with_asset_on_context_with_a_full_datasource_and_one_with_no_dataconnectors( deterministic_asset_dataconnector_context, ): context = deterministic_asset_dataconnector_context assert len(context.list_datasources()) == 1 context.add_datasource( "aaa_datasource", class_name="Datasource", module_name="great_expectations.datasource.new_datasource", execution_engine={ "class_name": "PandasExecutionEngine", "module_name": "great_expectations.execution_engine", }, ) assert len(context.list_datasources()) == 2 renderer = CheckpointNewNotebookRenderer(context, "foo") obs = renderer._find_datasource_with_asset() assert obs == { "datasource_name": "my_datasource", "data_connector_name": "my_other_data_connector", "asset_name": "users", }