Skip to content

Commit

Permalink
Brostk/3866 remove mypy test exclusions (#14)
Browse files Browse the repository at this point in the history
remove mypy tests exclusion and fix errors from 'poetry run mypy'; Add pytest as mypy add'l dependency.
  • Loading branch information
brostk authored Dec 16, 2024
1 parent 63db748 commit e74299f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ repos:
additional_dependencies:
- 'pydantic'
- 'fastapi'
- 'pytest'
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ plugins = ['pydantic.mypy']
strict = true
ignore_missing_imports = true
exclude = [
"scripts",
"tests",
"scripts"
]

[tool.poetry]
Expand Down
28 changes: 15 additions & 13 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Dict, List

from fastapi.testclient import TestClient

MAX_RATING = '/disability-max-ratings'
Expand All @@ -7,8 +9,8 @@
NOT_RATED = {'diagnostic_code': 9999}


def test_max_rating_with_no_dc(client: TestClient):
json_post_dict = {'diagnostic_codes': []}
def test_max_rating_with_no_dc(client: TestClient) -> None:
json_post_dict: Dict[str, List[int]] = {'diagnostic_codes': []}

response = client.post(MAX_RATING, json=json_post_dict)
assert response.status_code == 200
Expand All @@ -18,7 +20,7 @@ def test_max_rating_with_no_dc(client: TestClient):
assert len(ratings) == 0


def test_max_rating_with_one_dc(client: TestClient):
def test_max_rating_with_one_dc(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [TINNITUS['diagnostic_code']]}

response = client.post(MAX_RATING, json=json_post_dict)
Expand All @@ -31,7 +33,7 @@ def test_max_rating_with_one_dc(client: TestClient):
assert ratings[0]['max_rating'] == TINNITUS['max_rating']


def test_max_rating_with_multiple_dc(client: TestClient):
def test_max_rating_with_multiple_dc(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [TINNITUS['diagnostic_code'], TUBERCULOSIS['diagnostic_code']]}

response = client.post(MAX_RATING, json=json_post_dict)
Expand All @@ -46,7 +48,7 @@ def test_max_rating_with_multiple_dc(client: TestClient):
assert ratings[1]['max_rating'] == TUBERCULOSIS['max_rating']


def test_max_rating_with_duplicate_dc(client: TestClient):
def test_max_rating_with_duplicate_dc(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [TINNITUS['diagnostic_code'], TINNITUS['diagnostic_code']]}

response = client.post(MAX_RATING, json=json_post_dict)
Expand All @@ -58,14 +60,14 @@ def test_max_rating_with_duplicate_dc(client: TestClient):
assert ratings[0]['max_rating'] == TINNITUS['max_rating']


def test_max_rating_with_too_many_dc(client: TestClient):
def test_max_rating_with_too_many_dc(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [*range(5000, 6001)]}

response = client.post(MAX_RATING, json=json_post_dict)
assert response.status_code == 422


def test_max_rating_with_unmapped_dc(client: TestClient):
def test_max_rating_with_unmapped_dc(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [NOT_RATED['diagnostic_code']]}

response = client.post(MAX_RATING, json=json_post_dict)
Expand All @@ -77,29 +79,29 @@ def test_max_rating_with_unmapped_dc(client: TestClient):
assert len(ratings) == 0


def test_max_rating_with_value_below_range(client: TestClient):
def test_max_rating_with_value_below_range(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [4999]}

response = client.post(MAX_RATING, json=json_post_dict)
assert response.status_code == 400


def test_max_rating_with_value_above_range(client: TestClient):
def test_max_rating_with_value_above_range(client: TestClient) -> None:
json_post_dict = {'diagnostic_codes': [10001]}

response = client.post(MAX_RATING, json=json_post_dict)
assert response.status_code == 400


def test_missing_params(client: TestClient):
def test_missing_params(client: TestClient) -> None:
"""should fail if all required params are not present"""
json_post_dict = {}
json_post_dict: Dict[str, List[int]] = {}

response = client.post(MAX_RATING, json=json_post_dict)
assert response.status_code == 422


def test_unprocessable_content_request_does_not_have_array(client: TestClient):
def test_unprocessable_content_request_does_not_have_array(client: TestClient) -> None:
json_post_dict = {
'diagnostic_codes': 6510, # Should be an array
}
Expand All @@ -108,7 +110,7 @@ def test_unprocessable_content_request_does_not_have_array(client: TestClient):
assert response.status_code == 422


def test_unprocessable_content_request_array_has_non_int_value(client: TestClient):
def test_unprocessable_content_request_array_has_non_int_value(client: TestClient) -> None:
json_post_dict = {
'diagnostic_codes': ['6510'], # Should be an int
}
Expand Down

0 comments on commit e74299f

Please sign in to comment.