diff --git a/makedoc/tests/conftest.py b/makedoc/tests/conftest.py index e8d0f0b..89c72bc 100644 --- a/makedoc/tests/conftest.py +++ b/makedoc/tests/conftest.py @@ -11,11 +11,6 @@ def user(django_user_model): password='testpassword') -@pytest.fixture -def api_client() -> APIClient: - return APIClient() - - @pytest.fixture def authorized_client(user): client = APIClient() diff --git a/makedoc/tests/test_views_makedoc.py b/makedoc/tests/test_views_makedoc.py index 4c54702..9c126e3 100644 --- a/makedoc/tests/test_views_makedoc.py +++ b/makedoc/tests/test_views_makedoc.py @@ -4,7 +4,8 @@ @pytest.mark.django_db -def test_data_doc_view_status_code(api_client: APIClient) -> None: +def test__data_view__unauthorized_user_cannot_post_data() -> None: + client = APIClient() url = reverse('data') data = { "client_id": 123, @@ -15,12 +16,12 @@ def test_data_doc_view_status_code(api_client: APIClient) -> None: "factory_id": 1, "destination": "New York" } - response = api_client.post(url, data, format='json') + response = client.post(url, data, format='json') assert response.status_code == 401 # Unauthorized @pytest.mark.django_db -def test_data_doc_view_response_data(authorized_client) -> None: +def test__goods__authorized_user_can_post_data(authorized_client) -> None: url = reverse('data') data = { "client_id": 123, @@ -33,4 +34,19 @@ def test_data_doc_view_response_data(authorized_client) -> None: } response = authorized_client.post(url, data, format='json') assert response.status_code == 200 + + +@pytest.mark.django_db +def test__goods__authorized_user_post_data_response_is_correct(authorized_client) -> None: + url = reverse('data') + data = { + "client_id": 123, + "items": [ + {"product_id": 1, "quantity": 2, "discount": 10}, + {"product_id": 2, "quantity": 5, "discount": 4} + ], + "factory_id": 1, + "destination": "New York" + } + response = authorized_client.post(url, data, format='json') assert response.json() == data