Browse Source

unchecked checkboxes are absent from html form input

pull/13464/head
sneakers-the-rat 2 months ago
parent
commit
be89bde3f8
No known key found for this signature in database GPG Key ID: 6DCB96EF1E4D232D
  1. 5
      tests/test_tutorial/test_request_form_models/test_tutorial003.py
  2. 5
      tests/test_tutorial/test_request_form_models/test_tutorial004.py

5
tests/test_tutorial/test_request_form_models/test_tutorial003.py

@ -33,11 +33,12 @@ def test_post_form_checked(client: TestClient):
assert response.json() == {"checkbox": True} assert response.json() == {"checkbox": True}
def test_post_form_unchecked(client: TestClient): @pytest.mark.parametrize("data", [{}, {"checkbox": ""}])
def test_post_form_unchecked(client: TestClient, data: dict):
""" """
When the checkbox is not checked, When the checkbox is not checked,
the value is (maybe correctly but undesirably) still True the value is (maybe correctly but undesirably) still True
""" """
response = client.post("/form", data={"checkbox": ""}) response = client.post("/form", data=data)
response.raise_for_status() response.raise_for_status()
assert response.json() == {"checkbox": True} assert response.json() == {"checkbox": True}

5
tests/test_tutorial/test_request_form_models/test_tutorial004.py

@ -33,12 +33,13 @@ def test_post_form_checked(client: TestClient):
assert response.json() == {"checkbox": True} assert response.json() == {"checkbox": True}
def test_post_form_unchecked(client: TestClient): @pytest.mark.parametrize("data", [{}, {"checkbox": ""}])
def test_post_form_unchecked(client: TestClient, data: dict):
""" """
When the checkbox is not checked, When the checkbox is not checked,
now that we have a model validator that can differentiate defaults vs. undefined, now that we have a model validator that can differentiate defaults vs. undefined,
the checkbox is correctly false. the checkbox is correctly false.
""" """
response = client.post("/form", data={"checkbox": ""}) response = client.post("/form", data=data)
response.raise_for_status() response.raise_for_status()
assert response.json() == {"checkbox": False} assert response.json() == {"checkbox": False}

Loading…
Cancel
Save