def test__find_all_evrs_by_type(titanic_profiled_evrs_1): # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evrs = Renderer()._find_all_evrs_by_type( titanic_profiled_evrs_1.results, "expect_column_to_exist", column_=None) print(found_evrs) assert found_evrs == [] # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evrs = Renderer()._find_all_evrs_by_type( titanic_profiled_evrs_1.results, "expect_column_to_exist", column_="SexCode") print(found_evrs) assert found_evrs == [] # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evrs = Renderer()._find_all_evrs_by_type( titanic_profiled_evrs_1.results, "expect_column_distinct_values_to_be_in_set", column_=None, ) print(found_evrs) assert len(found_evrs) == 4 # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evrs = Renderer()._find_all_evrs_by_type( titanic_profiled_evrs_1.results, "expect_column_distinct_values_to_be_in_set", column_="SexCode", ) print(found_evrs) assert len(found_evrs) == 1
def test__find_evr_by_type(titanic_profiled_evrs_1): # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evr = Renderer()._find_evr_by_type(titanic_profiled_evrs_1.results, "expect_column_to_exist") print(found_evr) assert found_evr is None # TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite.results found_evr = Renderer()._find_evr_by_type( titanic_profiled_evrs_1.results, "expect_column_distinct_values_to_be_in_set") print(found_evr) assert found_evr == ExpectationValidationResult( success=True, result={ "observed_value": ["*", "1st", "2nd", "3rd"], "element_count": 1313, "missing_count": 0, "missing_percent": 0.0, "details": { "value_counts": [ { "value": "*", "count": 1 }, { "value": "1st", "count": 322 }, { "value": "2nd", "count": 279 }, { "value": "3rd", "count": 711 }, ] }, }, exception_info={ "raised_exception": False, "exception_message": None, "exception_traceback": None, }, expectation_config=ExpectationConfiguration( expectation_type="expect_column_distinct_values_to_be_in_set", kwargs={ "column": "PClass", "value_set": None, "result_format": "SUMMARY" }, ), )
def test_render(): # noinspection PyUnusedLocal with pytest.raises(NotImplementedError) as e: Renderer().render(**{}) # noinspection PyUnusedLocal with pytest.raises(TypeError) as e: # noinspection PyArgumentList Renderer().render({}) # noinspection PyUnusedLocal with pytest.raises(TypeError) as e: # noinspection PyArgumentList Renderer().render("wowza")
def test__find_evr_by_type(titanic_profiled_evrs_1): #TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite["results"] found_evr = Renderer()._find_evr_by_type( titanic_profiled_evrs_1["results"], "expect_column_to_exist") print(found_evr) assert found_evr == None #TODO: _find_all_evrs_by_type should accept an ValidationResultSuite, not ValidationResultSuite["results"] found_evr = Renderer()._find_evr_by_type( titanic_profiled_evrs_1["results"], "expect_column_distinct_values_to_be_in_set") print(found_evr) assert found_evr == { 'success': True, 'result': { 'observed_value': ['*', '1st', '2nd', '3rd'], 'element_count': 1313, 'missing_count': 0, 'missing_percent': 0.0, 'details': { 'value_counts': [{ 'value': '*', 'count': 1 }, { 'value': '1st', 'count': 322 }, { 'value': '2nd', 'count': 279 }, { 'value': '3rd', 'count': 711 }] } }, 'exception_info': { 'raised_exception': False, 'exception_message': None, 'exception_traceback': None }, 'expectation_config': { 'expectation_type': 'expect_column_distinct_values_to_be_in_set', 'kwargs': { 'column': 'PClass', 'value_set': None, 'result_format': 'SUMMARY' } } }
def test__get_column_list_from_evrs(titanic_profiled_evrs_1): column_list = Renderer()._get_column_list_from_evrs( titanic_profiled_evrs_1) print(column_list) assert column_list == [ 'Unnamed: 0', 'Name', 'PClass', 'Age', 'Sex', 'Survived', 'SexCode' ]
def test__get_column_list_from_evrs(titanic_profiled_evrs_1): column_list = Renderer()._get_column_list_from_evrs(titanic_profiled_evrs_1) print(column_list) assert column_list == [ "Unnamed: 0", "Name", "PClass", "Age", "Sex", "Survived", "SexCode", ]
def titanic_profiled_name_column_expectations(): from great_expectations.render.renderer.renderer import ( Renderer, ) titanic_profiled_expectations = json.load( open("./tests/render/fixtures/BasicDatasetProfiler_expectations.json")) columns, ordered_columns = Renderer( )._group_and_order_expectations_by_column(titanic_profiled_expectations) print(columns) print(ordered_columns) name_column_expectations = columns["Name"] print(json.dumps(name_column_expectations, indent=2)) return name_column_expectations
def titanic_profiled_name_column_evrs(): #This is a janky way to fetch expectations matching a specific name from an EVR suite. #TODO: It will no longer be necessary once we implement ValidationResultSuite._group_evrs_by_column from great_expectations.render.renderer.renderer import ( Renderer, ) titanic_profiled_evrs_1 = json.load( open("./tests/render/fixtures/BasicDatasetProfiler_evrs.json")) evrs_by_column = Renderer()._group_evrs_by_column(titanic_profiled_evrs_1) print(evrs_by_column.keys()) name_column_evrs = evrs_by_column["Name"] print(json.dumps(name_column_evrs, indent=2)) return name_column_evrs
def titanic_profiled_name_column_evrs(): # This is a janky way to fetch expectations matching a specific name from an EVR suite. # TODO: It will no longer be necessary once we implement ValidationResultSuite._group_evrs_by_column from great_expectations.render.renderer.renderer import Renderer with open( file_relative_path( __file__, "./fixtures/BasicDatasetProfiler_evrs.json"), ) as infile: titanic_profiled_evrs_1 = expectationSuiteValidationResultSchema.load( json.load(infile)) evrs_by_column = Renderer()._group_evrs_by_column(titanic_profiled_evrs_1) name_column_evrs = evrs_by_column["Name"] return name_column_evrs
def test_ProfilingResultsColumnSectionRenderer_render( titanic_profiled_evrs_1, titanic_profiled_name_column_evrs): #Smoke test for titanic names document = ProfilingResultsColumnSectionRenderer().render( titanic_profiled_name_column_evrs) print(document) assert document != {} #Smoke test for titanic Ages #This is a janky way to fetch expectations matching a specific name from an EVR suite. #TODO: It will no longer be necessary once we implement ValidationResultSuite._group_evrs_by_column from great_expectations.render.renderer.renderer import ( Renderer, ) evrs_by_column = Renderer()._group_evrs_by_column(titanic_profiled_evrs_1) print(evrs_by_column.keys()) age_column_evrs = evrs_by_column["Age"] print(json.dumps(age_column_evrs, indent=2)) document = ProfilingResultsColumnSectionRenderer().render(age_column_evrs) print(document)
def test_render(): # ??? Should this really return the input object? # Seems like raising NotImplementedError might be preferable. assert Renderer().render({}) == {} assert Renderer().render("wowza") == "wowza"