Example #1
0
    def test_error_message_is_present_if_question_error_is_in_errors(self, question):
        errors = {
            "question": {
                "input_name": "question",
                "href": "#input-question",
                "question": "Yes or no?",
                "message": "Answer yes or no.",
            }
        }

        assert _params(question, errors=errors)["errorMessage"] == {
            "text": "Answer yes or no."
        }
Example #2
0
    def test_error_message_is_not_present_if_question_error_is_not_in_errors(
        self, question
    ):
        errors = {
            "another_question": {
                "input_name": "another-question",
                "href": "#input-another-question",
                "question": "Are you sure?",
                "message": "Enter whether you are sure or not.",
            }
        }

        assert "errorMessage" not in _params(question, errors=errors)
Example #3
0
    def test_value_and_error_message(self, question):
        data = {"question": "Definitely"}
        errors = {
            "question": {
                "input_name": "question",
                "href": "#input-question",
                "question": "Yes or no?",
                "message": "Answer yes or no only.",
            }
        }

        params = _params(question, data, errors)
        assert params["value"] == "Definitely"
        assert params["errorMessage"]["text"] == "Answer yes or no only."
Example #4
0
    def test_error_message_is_not_present_if_question_error_is_none(self, question):
        errors = {"another_question": None}

        assert "errorMessage" not in _params(question, errors=errors)
Example #5
0
    def test_value_is_present_if_question_answer_is_in_data(self, question):
        data = {"question": "Yes"}

        assert _params(question, data)["value"] == "Yes"
Example #6
0
    def test_value_is_not_present_if_question_answer_is_none(self, question):
        data = {"another_question": None}

        assert "value" not in _params(question, data)
Example #7
0
    def test_hint_classes_kwarg(self, question):
        question.hint = "Choose yes or no"

        assert _params(question, hint_classes=["app-hint"])["hint"]["classes"] == "app-hint"
Example #8
0
    def test_hint(self, question):
        question.hint = "Answer yes or no"

        assert _params(question)["hint"] == {
            "text": "Answer yes or no",
        }
Example #9
0
 def test_input_id_kwarg(self, question):
     params = _params(question, input_id="question")
     assert params["id"] == "input-question"
     assert params["name"] == "question"
Example #10
0
 def test_classes_kwarg(self, question):
     assert _params(question, classes=["app-input"])["classes"] == "app-input"
     assert _params(question, classes=["app-input", "app-input--l"])["classes"] == "app-input app-input--l"
Example #11
0
 def test__params(self, question):
     assert _params(question) == {
         "id": "input-question",
         "name": "question",
     }