Esempio n. 1
0
def test_to_html_returns_html_with_multiquestion_sub_types(content_summary):
    question = content_summary.get_question("myMultiquestionWithMultipleTypes")
    expected = dedent("""\
    <p class="govuk-body govuk-!-margin-top-0 govuk-!-margin-bottom-1">Text question</p>
    <div>Multiquestion text answer</div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">List question</p>
    <div><ul class="govuk-list govuk-list--bullet">
      <li>Hello</li>
      <li>World</li>
    </ul></div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">Checkbox question</p>
    <div><ul class="govuk-list govuk-list--bullet">
      <li>Check 1</li>
      <li>Check 2</li>
    </ul></div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">Boolean question</p>
    <div>Yes</div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">Boolean list question</p>
    <div><ul class="govuk-list govuk-list--bullet">
      <li>Yes</li>
      <li>No</li>
    </ul></div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">Radios question</p>
    <div>Selected radio value</div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">Upload question</p>
    <div><a class="govuk-link" href="#">Upload question</a></div>""")
    assert to_html(question) == expected
Esempio n. 2
0
def test_to_html_returns_html_list_if_question_type_is_list(content_summary):
    list_question = content_summary.get_question("mySimpleList")
    expected = dedent("""\
    <ul class="govuk-list govuk-list--bullet">
      <li>Hello</li>
      <li>World</li>
    </ul>""")

    assert to_html(list_question) == expected
Esempio n. 3
0
def test_to_html_returns_html_if_question_type_is_multiquestion(
        content_summary):
    question = content_summary.get_question("myMultiquestion")
    expected = dedent("""\
    <p class="govuk-body govuk-!-margin-top-0 govuk-!-margin-bottom-1">MQ One</p>
    <div>Multiquestion answer 1</div>
    <p class="govuk-body govuk-!-margin-top-3 govuk-!-margin-bottom-1">MQ Two</p>
    <div>Multiquestion answer 2</div>""")
    assert to_html(question) == expected
Esempio n. 4
0
def test_to_html_returns_html_list_if_question_type_is_checkboxes(
        content_summary):
    integer_question = content_summary.get_question("myCheckbox")
    expected = dedent("""\
    <ul class="govuk-list govuk-list--bullet">
      <li>Check 1</li>
      <li>Check 2</li>
    </ul>""")

    assert to_html(integer_question) == expected
Esempio n. 5
0
def test_to_html_returns_html_which_is_safe_for_jinja(content_summary,
                                                      question, expected,
                                                      autoescape):
    question = content_summary.get_question(question)
    html = to_html(question)

    env = jinja2.Environment(autoescape=autoescape)
    template = env.from_string("{{ html }}")

    assert template.render(html=html) == expected
Esempio n. 6
0
def test_to_html_returns_html_list_if_question_type_is_boolean_list(
        content_summary):
    boolean_list_question = content_summary.get_question("myBooleanList")
    expected = dedent("""\
    <ul class="govuk-list govuk-list--bullet">
      <li>Yes</li>
      <li>No</li>
      <li>No</li>
      <li>Yes</li>
    </ul>""")

    assert to_html(boolean_list_question) == expected
Esempio n. 7
0
def test_to_html_can_capitalize_first(content_summary, question, expected):
    question = content_summary.get_question(question)
    assert to_html(question, capitalize_first=True) == expected
Esempio n. 8
0
def test_to_html_can_format_links(content_summary, question, expected):
    question = content_summary.get_question(question)
    assert to_html(question, format_links=True) == expected
Esempio n. 9
0
def test_to_html_returns_wrapped_anchor_if_question_type_is_upload(
        content_summary):
    question = content_summary.get_question("myUpload")
    assert to_html(
        question) == '<a class="govuk-link" href="#">Upload Question</a>'
Esempio n. 10
0
def test_to_html_preserves_line_breaks_for_textbox_large_questions(
        content_summary):
    question = content_summary.get_question("myMultipleLines")
    assert to_html(question) == Markup(
        "Text with multiple lines.<br><br>This is the second line.")
Esempio n. 11
0
def test_to_html_returns_text_for_date_question(content_summary):
    question = content_summary.get_question("myDate")

    assert to_html(question) == "Thursday 18 February 2016"
Esempio n. 12
0
def test_to_html_returns_text_for_pricing_question(content_summary):
    question = content_summary.get_question("myPricing")

    assert to_html(question) == "£20.41 to £25.00"
Esempio n. 13
0
def test_to_html_returns_yes_if_boolean_true(content_summary):
    question = content_summary.get_question("myBooleanTrue")
    assert to_html(question) == "Yes"
Esempio n. 14
0
def test_to_html_returns_html_text_if_question_type_is_checkboxes_and_answer_has_only_one_item(
        content_summary):
    question = content_summary.get_question("myCheckboxWithOneItem")

    assert to_html(question) == "check 2"
Esempio n. 15
0
def test_to_html_returns_value(content_summary):
    question = content_summary.get_question("myEmptyString")
    assert to_html(question) == ""
Esempio n. 16
0
def test_to_html_can_format_links_which_open_in_a_new_tab(
        content_summary, question, expected):
    question = content_summary.get_question(question)
    assert to_html(question, format_links=True,
                   open_links_in_new_tab=True) == expected
Esempio n. 17
0
def test_to_html_returns_no_if_boolean_false(content_summary):
    question = content_summary.get_question("myBooleanFalse")
    assert to_html(question) == "No"
Esempio n. 18
0
def test_to_html_returns_text_as_html(content_summary):
    question = content_summary.get_question("mySimpleText")
    assert to_html(question) == "Hello World"
Esempio n. 19
0
def test_to_html_returns_text_for_number(content_summary):
    integer_question = content_summary.get_question("myInteger")
    float_question = content_summary.get_question("myFloat")
    assert to_html(integer_question) == "7"
    assert to_html(float_question) == "23.45"
Esempio n. 20
0
def test_to_html_returns_text_if_question_type_is_radios(content_summary):
    question = content_summary.get_question("myRadio")
    assert to_html(question) == "Selected radio value"
Esempio n. 21
0
def test_to_html_raises_error_if_value_is_not_valid():
    with pytest.raises(TypeError):
        to_html(None)