Coverage for tests/tests_api/misc/clients.py: 45%
22 statements
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-10 03:02 +0300
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-10 03:02 +0300
1import pytest
2from sotrans_models.models.misc.client import ClientCreateModel, ClientDBModel
4from ...conftest import APIDataStorage
5from ...random_model import generate_models_json
6from ...tests_api.auth import test_client, token
9def test_create_client(test_client):
10 model_dump = generate_models_json(
11 ClientCreateModel, {"name": "Testerito", "inn": "1234567890"}
12 )
13 resp = test_client.post("/clients", json=model_dump)
14 assert resp.status_code == 201
15 APIDataStorage.client = ClientDBModel(**resp.json())
18def test_get_client_by_id(test_client):
19 resp = test_client.get(f"/clients/{APIDataStorage.client.id}")
20 assert resp.status_code == 200
21 assert ClientDBModel(**resp.json()).inn == APIDataStorage.client.inn
24def test_update_client(test_client):
25 resp = test_client.patch(
26 f"/clients/{APIDataStorage.client.id}",
27 json={"name": "William inc.", "etag": None},
28 )
29 assert resp.status_code == 200
30 assert ClientDBModel(**resp.json()).name == "William inc."
33@pytest.mark.skip
34def test_delete_client(test_client):
35 resp = test_client.delete(f"/clients/{APIDataStorage.client.id}")
36 assert resp.content == 204