From 0e0b1d42deb4e04c5f3df6658df4473c3fc89dd8 Mon Sep 17 00:00:00 2001 From: Tom Amberson Date: Thu, 31 Oct 2024 10:24:13 -0600 Subject: [PATCH] test: add tests for double check --- tests/test_hebikani.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_hebikani.py b/tests/test_hebikani.py index 8a97f8a..da73814 100644 --- a/tests/test_hebikani.py +++ b/tests/test_hebikani.py @@ -337,6 +337,35 @@ def test_question_add_wrong_answers(): assert question.wrong_answer_count == 2 +# first value is input for answer; the second is input for double_check +@patch("builtins.input", side_effect=["change me to correct", "y"]) +def test_double_check_y(input_mock): + """Test if the question is not marked wrong when double check overrides it.""" + subject = Subject(get_specific_subjects["data"][0]) + options = ClientOptions(double_check=True) + client = Client(API_KEY, options) + session = ReviewSession(client, [subject]) + question = subject.meaning_question + answer_type = session.ask_answer(question) + print(answer_type) + session.process_answer(question, answer_type) + assert question.wrong_answer_count == 0 + + +# first value is input for answer; the second is input for double_check +@patch("builtins.input", side_effect=["leave me incorrect", "n"]) +def test_double_check_n(input_mock): + """Test if the question is marked wrong when double check does not override it.""" + subject = Subject(get_specific_subjects["data"][0]) + options = ClientOptions(double_check=True) + client = Client(API_KEY, options) + session = ReviewSession(client, [subject]) + question = subject.meaning_question + answer_type = session.ask_answer(question) + session.process_answer(question, answer_type) + assert question.wrong_answer_count == 1 + + def test_question_answer_values(): """Test the question answer values.""" subject = Subject(double_reading_subject)