|
| 1 | +import pytest |
| 2 | + |
| 3 | + |
| 4 | +@pytest.mark.asyncio |
| 5 | +class TestList: |
| 6 | + @pytest.mark.parametrize("num_clients", [0, 1, 2]) |
| 7 | + async def test_valid_data_is_parsed_properly(self, client, httpserver, clients_data): |
| 8 | + httpserver.expect_request("/clients/", "GET").respond_with_json(clients_data[0]) |
| 9 | + clients = await client.clients.list() |
| 10 | + assert clients == clients_data[1] |
| 11 | + |
| 12 | + |
| 13 | +@pytest.mark.asyncio |
| 14 | +class TestGet: |
| 15 | + @pytest.mark.parametrize("num_clients", [1]) |
| 16 | + async def test_valid_data_is_parsed_properly(self, client, httpserver, clients_data): |
| 17 | + expected_client = clients_data[1][0] |
| 18 | + clients_json = clients_data[0][0] |
| 19 | + |
| 20 | + httpserver.expect_request(f"/clients/{expected_client.id}/", "GET").respond_with_json( |
| 21 | + clients_json |
| 22 | + ) |
| 23 | + client = await client.clients.get(expected_client.id) |
| 24 | + assert client == expected_client |
| 25 | + |
| 26 | + |
| 27 | +@pytest.mark.asyncio |
| 28 | +class TestVerify: |
| 29 | + @pytest.mark.parametrize("num_clients", [1]) |
| 30 | + async def test_valid_data_is_parsed_properly(self, client, httpserver, clients_data): |
| 31 | + expected_client = clients_data[1][0] |
| 32 | + clients_json = clients_data[0][0] |
| 33 | + |
| 34 | + httpserver.expect_request( |
| 35 | + f"/clients/verify/", "POST", json={"token": "123"} |
| 36 | + ).respond_with_json(clients_json) |
| 37 | + client = await client.clients.verify("123") |
| 38 | + assert client == expected_client |
0 commit comments