def has_equal_title(state): selector = state_selector(state) state.do_tests([ EqualityTest(*selector("title"), "The title is not correct."), EqualityTest(*selector("subtitle"), "The subtitle is not correct."), ]) return state
def has_equal_domain(state): domain_path = {"basicChart": "basicChart.domains.0.domain.sourceRange.sources.0"} if state.node_name in domain_path: state.do_test( EqualityTest( *state_selector(state)(domain_path[state.node_name]), "the X-axis is not correct.", ) ) return state
def has_equal_node(state, test, path, message): test_classes = { "equality": EqualityTest, "array_equal_length": ArrayEqualLengthTest, "array_equality": partial(array_element_tests, EqualityTest), } tests = test_classes.get(test)(*state_selector(state)(path), message) if not isinstance(tests, list): tests = [tests] state.do_tests(tests) return state
def has_equal_single_series(state, number, min_range_str, series_type): base_path = f"basicChart.series.{number - 1}" min_range = Range(min_range_str) series_path = { "basicChart": { "source": f"{base_path}.series.sourceRange.sources", "color": f"{base_path}.color", } } series_equality = {"source": partial(equal_sources, min_range=min_range)} ordinal = selectors.get_ord(number) if state.node_name in series_path: state.do_test( EqualityTest( *state_selector(state)(series_path[state.node_name].get(series_type)), f"the {ordinal} series' {series_type} is not correct.", series_equality.get(series_type, lambda x, y: x == y), ) ) return state
def has_equal_series(state): series_path = { "basicChart": { "source": ("basicChart.series", ["series.sourceRange.sources"]), "color": ("basicChart.series", ["color"]), } } if state.node_name in series_path: selector = state_selector(state) state.do_tests( array_element_tests( EqualityTest, *selector(series_path[state.node_name].get("source")), state.build_message("the {ordinal} series' source is not correct."), ) + array_element_tests( EqualityTest, *selector(series_path[state.node_name].get("color")), state.build_message("the {ordinal} series' color is not correct."), ) ) return state