def test_add_empty_data_point(): data_point = {} existing_manifest: Dict[str, Set[str]] = { "district": {"4"}, "month": {"11"}, "supervision_type": {"parole", "probation"}, "year": {"2020"}, } with pytest.raises(KeyError): optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest)
def test_add_empty_data_point(): data_point = {} existing_manifest: Dict[str, Set[str]] = { 'district': {'4'}, 'month': {'11'}, 'supervision_type': {'parole', 'probation'}, 'year': {'2020'}, } with pytest.raises(KeyError): optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest)
def test_add_data_point_with_empty_values(self): data_point = { "district": None, "month": None, "supervision_type": None, "year": None, } existing_manifest: Dict[str, Set[str]] = { "district": {"4"}, "month": {"11"}, "supervision_type": {"parole", "probation"}, "year": {"2020"}, } expected: Dict[str, Set[str]] = { "district": {"4", "none"}, "month": {"11", "none"}, "supervision_type": {"parole", "probation", "none"}, "year": {"2020", "none"}, } updated_manifest = ( optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest)) self.assertEqual(expected, updated_manifest)
def test_add_data_point_with_empty_values(self): data_point = { 'district': None, 'month': None, 'supervision_type': None, 'year': None, } existing_manifest: Dict[str, Set[str]] = { 'district': {'4'}, 'month': {'11'}, 'supervision_type': {'parole', 'probation'}, 'year': {'2020'}, } expected: Dict[str, Set[str]] = { 'district': {'4', 'none'}, 'month': {'11', 'none'}, 'supervision_type': {'parole', 'probation', 'none'}, 'year': {'2020', 'none'}, } updated_manifest = optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest) self.assertEqual(expected, updated_manifest)
def test_add_to_existing_dimensions(self): data_point = _DATA_POINTS[2] existing_manifest: Dict[str, Set[str]] = { 'district': {'4'}, 'month': {'11'}, 'supervision_type': {'parole', 'probation'}, 'year': {'2020'}, } expected = { 'district': {'4', '5'}, 'month': {'11'}, 'supervision_type': {'parole', 'probation'}, 'year': {'2020'}, } updated_manifest = optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest) self.assertEqual(expected, updated_manifest)
def test_add_all_new_dimensions(self): data_point = _DATA_POINTS[2] fresh_manifest: Dict[str, Set[str]] = { 'district': set(), 'month': set(), 'supervision_type': set(), 'year': set(), } expected = { 'district': {'5'}, 'month': {'11'}, 'supervision_type': {'parole'}, 'year': {'2020'}, } updated_manifest = optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, fresh_manifest) self.assertEqual(expected, updated_manifest)
def test_add_to_existing_dimensions(self): data_point = _DATA_POINTS[2] existing_manifest: Dict[str, Set[str]] = { "district": {"4"}, "month": {"11"}, "supervision_type": {"parole", "probation"}, "year": {"2020"}, } expected = { "district": {"4", "5"}, "month": {"11"}, "supervision_type": {"parole", "probation"}, "year": {"2020"}, } updated_manifest = ( optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, existing_manifest)) self.assertEqual(expected, updated_manifest)
def test_add_all_new_dimensions(self): data_point = _DATA_POINTS[2] fresh_manifest: Dict[str, Set[str]] = { "district": set(), "month": set(), "supervision_type": set(), "year": set(), } expected = { "district": {"5"}, "month": {"11"}, "supervision_type": {"parole"}, "year": {"2020"}, } updated_manifest = ( optimized_metric_big_query_view_exporter.add_to_dimension_manifest( data_point, fresh_manifest)) self.assertEqual(expected, updated_manifest)