def test_check_function(): user_data = {"formulas": [["SUM(B1)"]]} s = setup_state(user_data, user_data, "A1") with pytest.raises( TF, match=r"In cell `A1`, did you use the `AVERAGE\(\)` function\?"): check_function(s, name="AVERAGE")
def test_has_equal_reference_bas(): s = setup_state({"formulas": [["=$A$1"]]}, {"formulas": [["=$B$1"]]}, "A1") with pytest.raises( TF, match=r"In cell `A1`, did you use the absolute reference `\$B\$1`\?" ): has_equal_references(s, absolute=True)
def test_check_charts_trans_on_solution(solution_data, trans, correct): user_data = deepcopy(solution_data) solution_data = trans(deepcopy(solution_data)) # sct_range is irrelevant in charts s = setup_state(user_data, solution_data, "A1") with verify_success(correct): has_equal_charts(s)
def test_check_range(field, field_msg, patt): s = setup_state( { "values": [[1]], "formulas": [["=1"]] }, { "values": [[1, 2]], "formulas": [["=1"]] }, "B1", ) with pytest.raises(TF, match=patt): check_range(s, field, field_msg)
def test_format_string_messaging(): s = setup_state( { "values": [["A", "B"]], "formulas": [["=A1", "=B1"]] }, { "values": [["A", "A"]], "formulas": [["=A1", "=A1"]] }, "A1", ) with pytest.raises(TF, match=r"Check cell `A1` again."): check_operator(s, operator="<", missing_msg="Check cell `{range}` again.")
def test_check_pivot_calculated_fields(solution_data_calculated_field, trans, sct_range, correct, message_contains): user_data = trans(deepcopy(solution_data_calculated_field)) s = setup_state(user_data, solution_data_calculated_field, sct_range) with verify_success(correct, message_contains): has_equal_pivot(s)
def test_has_equal_reference(): s = setup_state({"formulas": [["=A1"]]}, {"formulas": [["=B1"]]}, "A1") with pytest.raises( TF, match=r"In cell `A1`, did you use the reference `B1`\?"): has_equal_references(s)
def test_has_equal_formula(): s = setup_state({"formulas": [["=1"]]}, {"formulas": [["=2"]]}, "A1") with pytest.raises( TF, match=r"In cell `A1`, did you use the correct formula\?"): has_equal_formula(s)
def test_has_equal_value(): s = setup_state({"values": [[1]]}, {"values": [[2]]}, "A1") with pytest.raises(TF, match=r"The value at `A1` is not correct."): has_equal_value(s)
def test_check_operator(): user_data = {"formulas": [["=1 + 2"]]} s = setup_state(user_data, user_data, "A1") with pytest.raises(TF, match=r"In cell `A1`, did you use the `/` operator\?"): check_operator(s, operator="/")
def test_check_operator_normalize(user_data_normalize, sct_range, operator, correct): s = setup_state(user_data_normalize, user_data_normalize, sct_range) with verify_success(correct): check_operator(s, operator=operator)
def test_check_function_normalize(user_data_normalize, sct_range, function, correct): s = setup_state(user_data_normalize, user_data_normalize, sct_range) with verify_success(correct): check_function(s, name=function)
def test_check_pivots_two_values(solution_data_two_values, trans, sct_range, correct, message_contains): user_data = trans(deepcopy(solution_data_two_values)) s = setup_state(user_data, solution_data_two_values, sct_range) with verify_success(correct, message_contains): has_equal_pivot(s)
def test_has_equal_formula_normalization(user_data_norm_seed, trans, sct_range, correct): user_data = trans(deepcopy(user_data_norm_seed)) s = setup_state(user_data, user_data_norm_seed, sct_range) with verify_success(correct): has_equal_formula(s)
def test_has_equal_number_format(user_data_seed, trans, sct_range, correct, match): user_data = trans(deepcopy(user_data_seed)) s = setup_state(user_data, user_data_seed, sct_range) with verify_success(correct, match=match): has_equal_number_format(s)
def test_has_equal_value_precision(user_data_seed, trans, sct_range, correct): user_data = trans(deepcopy(user_data_seed)) s = setup_state(user_data, user_data_seed, sct_range) with verify_success(correct): has_equal_value(s)
def test_check_range(user_data_seed, trans, sct_range, correct): user_data = trans(deepcopy(user_data_seed)) s = setup_state(user_data, user_data_seed, sct_range) with verify_success(correct): check_range(s, field="values", field_msg="value")
def test_check_absolute_references_normalize(solution_data_normalize, trans, sct_range, correct): user_data = trans(deepcopy(solution_data_normalize)) s = setup_state(user_data, solution_data_normalize, sct_range) with verify_success(correct): has_equal_references(s, absolute=True)
def test_has_code(): user_data = {"formulas": [["missing"]]} s = setup_state(user_data, user_data, "A1") with pytest.raises( TF, match=r"In cell `A1`, did you use the correct formula\?"): has_code(s, "something")
def test_check_function_index(user_data_index, sct_range, function, index, correct): s = setup_state(user_data_index, user_data_index, sct_range) with verify_success(correct): check_function(s, name=function, index=index)
def test_check_regex_fixed(user_data_seed, trans, sct_range, pattern, correct): user_data = trans(deepcopy(user_data_seed)) s = setup_state(user_data, user_data, sct_range) with verify_success(correct): has_code(s, pattern, fixed=True)
def test_has_equal_conditional_formats_2(solution_data_2, trans, correct, match): user_data = trans(deepcopy(solution_data_2)) # sct_range is irrelevant in conditional formats s = setup_state(user_data, solution_data_2, "A1") with verify_success(correct, match=match): has_equal_conditional_formats(s)
def test_check_reference(solution_data, trans, sct_range, correct): user_data = trans(deepcopy(solution_data)) s = setup_state(user_data, solution_data, sct_range) with verify_success(correct): has_equal_references(s)