def test_is_custom_parent_class_recognized_yes(): config = { "module_name": "tests.data_context.fixtures.plugins.my_custom_v3_api_datasource", "class_name": "MyCustomV3ApiDatasource", } datasource_anonymizer = DatasourceAnonymizer(salt=CONSISTENT_SALT) parent_class = datasource_anonymizer.is_parent_class_recognized( config=config) assert parent_class == "Datasource" config = { "module_name": "tests.data_context.fixtures.plugins.my_custom_v2_api_datasource", "class_name": "MyCustomV2ApiDatasource", } datasource_anonymizer = DatasourceAnonymizer(salt=CONSISTENT_SALT) parent_class = datasource_anonymizer.is_parent_class_recognized( config=config) assert parent_class == "PandasDatasource"
def test_is_parent_class_recognized_no(): parent_classes = [ "MyCustomNonDatasourceClass", "MyOtherCustomNonDatasourceClass" ] configs = [{ "name": "test_datasource", "class_name": parent_class, "module_name": "great_expectations.datasource", } for parent_class in parent_classes] datasource_anonymizer = DatasourceAnonymizer(salt=CONSISTENT_SALT) for idx in range(len(configs)): parent_class = datasource_anonymizer.is_parent_class_recognized( config=configs[idx]) assert parent_class != parent_classes[idx] assert parent_class is None
def test_is_parent_class_recognized_yes(): v2_batch_kwargs_api_datasources = [ "PandasDatasource", "SqlAlchemyDatasource", "SparkDFDatasource", "LegacyDatasource", ] v3_batch_request_api_datasources = [ "SimpleSqlalchemyDatasource", "Datasource", "BaseDatasource", ] parent_classes = v2_batch_kwargs_api_datasources + v3_batch_request_api_datasources configs = [{ "name": "test_datasource", "class_name": parent_class, "module_name": "great_expectations.datasource", } for parent_class in parent_classes] datasource_anonymizer = DatasourceAnonymizer(salt=CONSISTENT_SALT) for idx in range(len(configs)): parent_class = datasource_anonymizer.is_parent_class_recognized( config=configs[idx]) assert parent_class == parent_classes[idx]