Browse Source

Add `pragma: no cover` to make coverage pass

pull/14829/head
Yurii Motov 5 months ago
parent
commit
7fed2671c4
  1. 15
      tests/test_request_params/test_body/test_nullable_and_defaults.py
  2. 5
      tests/test_request_params/test_cookie/test_nullable_and_defaults.py
  3. 7
      tests/test_request_params/test_file/test_nullable_and_defaults.py
  4. 20
      tests/test_request_params/test_form/test_nullable_and_defaults.py
  5. 5
      tests/test_request_params/test_header/test_nullable_and_defaults.py
  6. 6
      tests/test_request_params/test_query/test_nullable_and_defaults.py

15
tests/test_request_params/test_body/test_nullable_and_defaults.py

@ -332,8 +332,9 @@ def test_nullable_required_no_embed_pass_null(path: str):
response = client.post(path, content="null") response = client.post(path, content="null")
assert mock_convert.call_count == 1, "Validator should be called once for the field" assert mock_convert.call_count == 1, "Validator should be called once for the field"
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == {"val": None} assert response.json() == {"val": None} # pragma: no cover
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -672,8 +673,9 @@ def test_nullable_non_required_no_embed_pass_null(path: str):
response = client.post(path, content="null") response = client.post(path, content="null")
assert mock_convert.call_count == 1, "Validator should be called once for the field" assert mock_convert.call_count == 1, "Validator should be called once for the field"
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == {"val": None} assert response.json() == {"val": None} # pragma: no cover
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -1019,8 +1021,9 @@ def test_nullable_with_non_null_default_no_embed_pass_null(path: str):
response = client.post(path, content="null") response = client.post(path, content="null")
assert mock_convert.call_count == 1, "Validator should be called once for the field" assert mock_convert.call_count == 1, "Validator should be called once for the field"
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == {"val": None} assert response.json() == {"val": None} # pragma: no cover
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

5
tests/test_request_params/test_cookie/test_nullable_and_defaults.py

@ -369,12 +369,13 @@ def test_nullable_with_non_null_default_missing(path: str):
assert mock_convert.call_count == 0, ( assert mock_convert.call_count == 0, (
"Validator should not be called if the value is missing" "Validator should not be called if the value is missing"
) )
assert response.status_code == 200 assert response.status_code == 200 # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": -1, "int_val": -1,
"str_val": "default", "str_val": "default",
"fields_set": IsOneOf(None, []), "fields_set": IsOneOf(None, []),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

7
tests/test_request_params/test_file/test_nullable_and_defaults.py

@ -417,11 +417,12 @@ def test_nullable_with_non_null_default_missing(path: str):
with patch(f"{__name__}.convert", Mock(wraps=convert)) as mock_convert: with patch(f"{__name__}.convert", Mock(wraps=convert)) as mock_convert:
response = client.post(path) response = client.post(path)
assert mock_convert.call_count == 0, ( assert mock_convert.call_count == 0, ( # pragma: no cover
"Validator should not be called if the value is missing" "Validator should not be called if the value is missing"
) )
assert response.status_code == 200 assert response.status_code == 200 # pragma: no cover
assert response.json() == {"file": None, "files": None} assert response.json() == {"file": None, "files": None} # pragma: no cover
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

20
tests/test_request_params/test_form/test_nullable_and_defaults.py

@ -180,8 +180,8 @@ def test_nullable_required_pass_empty_str(path: str):
(""), # str_val (""), # str_val
(["0"]), # list_val (["0"]), # list_val
] ]
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": None, "int_val": None,
"str_val": None, "str_val": None,
"list_val": [0], "list_val": [0],
@ -189,6 +189,7 @@ def test_nullable_required_pass_empty_str(path: str):
None, IsList("int_val", "str_val", "list_val", check_order=False) None, IsList("int_val", "str_val", "list_val", check_order=False)
), ),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -368,8 +369,8 @@ def test_nullable_non_required_pass_empty_str(path: str):
(""), # str_val (""), # str_val
(["0"]), # list_val (["0"]), # list_val
] ]
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": None, "int_val": None,
"str_val": None, "str_val": None,
"list_val": [0], "list_val": [0],
@ -377,6 +378,7 @@ def test_nullable_non_required_pass_empty_str(path: str):
None, IsList("int_val", "str_val", "list_val", check_order=False) None, IsList("int_val", "str_val", "list_val", check_order=False)
), ),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -522,13 +524,14 @@ def test_nullable_with_non_null_default_missing(path: str):
assert mock_convert.call_count == 0, ( assert mock_convert.call_count == 0, (
"Validator should not be called if the value is missing" "Validator should not be called if the value is missing"
) )
assert response.status_code == 200 assert response.status_code == 200 # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": -1, "int_val": -1,
"str_val": "default", "str_val": "default",
"list_val": [0], "list_val": [0],
"fields_set": IsOneOf(None, []), "fields_set": IsOneOf(None, []),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -567,8 +570,8 @@ def test_nullable_with_non_null_default_pass_empty_str(path: str):
(""), # str_val (""), # str_val
(["0"]), # list_val (["0"]), # list_val
] ]
assert response.status_code == 200, response.text assert response.status_code == 200, response.text # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": None, "int_val": None,
"str_val": None, "str_val": None,
"list_val": [0], "list_val": [0],
@ -576,6 +579,7 @@ def test_nullable_with_non_null_default_pass_empty_str(path: str):
None, IsList("int_val", "str_val", "list_val", check_order=False) None, IsList("int_val", "str_val", "list_val", check_order=False)
), ),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

5
tests/test_request_params/test_header/test_nullable_and_defaults.py

@ -483,13 +483,14 @@ def test_nullable_with_non_null_default_missing(path: str):
assert mock_convert.call_count == 0, ( assert mock_convert.call_count == 0, (
"Validator should not be called if the value is missing" "Validator should not be called if the value is missing"
) )
assert response.status_code == 200 assert response.status_code == 200 # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": -1, "int_val": -1,
"str_val": "default", "str_val": "default",
"list_val": [0], "list_val": [0],
"fields_set": IsOneOf(None, []), "fields_set": IsOneOf(None, []),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

6
tests/test_request_params/test_query/test_nullable_and_defaults.py

@ -426,6 +426,7 @@ def test_nullable_with_non_null_default_schema(path: str):
# default_factory is not reflected in OpenAPI schema # default_factory is not reflected in OpenAPI schema
assert parameters[2]["schema"]["default"] == [0] assert parameters[2]["schema"]["default"] == [0]
@pytest.mark.parametrize( @pytest.mark.parametrize(
"path", "path",
[ [
@ -445,13 +446,14 @@ def test_nullable_with_non_null_default_missing(path: str):
assert mock_convert.call_count == 0, ( assert mock_convert.call_count == 0, (
"Validator should not be called if the value is missing" "Validator should not be called if the value is missing"
) )
assert response.status_code == 200 assert response.status_code == 200 # pragma: no cover
assert response.json() == { assert response.json() == { # pragma: no cover
"int_val": -1, "int_val": -1,
"str_val": "default", "str_val": "default",
"list_val": [0], "list_val": [0],
"fields_set": IsOneOf(None, []), "fields_set": IsOneOf(None, []),
} }
# TODO: Remove 'no cover' when the issue is fixed
@pytest.mark.parametrize( @pytest.mark.parametrize(

Loading…
Cancel
Save