userver: samples/postgres_service/tests/test_postgres.py
Loading...
Searching...
No Matches
samples/postgres_service/tests/test_postgres.py
1# /// [Functional test]
2async def test_postgres(service_client):
3 response = await service_client.delete('/v1/key-value?key=hello')
4 assert response.status == 200
5
6 response = await service_client.post('/v1/key-value?key=hello&value=world')
7 assert response.status == 201
8 assert 'text/plain' in response.headers['Content-Type']
9 assert response.text == 'world'
10
11 response = await service_client.get('/v1/key-value?key=hello')
12 assert response.status == 200
13 assert 'text/plain' in response.headers['Content-Type']
14 assert response.text == 'world'
15
16 response = await service_client.delete('/v1/key-value?key=hello')
17 assert response.status == 200
18
19 response = await service_client.post('/v1/key-value?key=hello&value=there')
20 assert response.status == 201
21 assert 'text/plain' in response.headers['Content-Type']
22 assert response.text == 'there'
23 # /// [Functional test]
24
25 response = await service_client.get('/v1/key-value?key=hello')
26 assert response.status == 200
27 assert 'text/plain' in response.headers['Content-Type']
28 assert response.text == 'there'
29
30 response = await service_client.post('/v1/key-value?key=hello&value=again')
31 assert response.status == 409
32 assert 'text/plain' in response.headers['Content-Type']
33 assert response.text == 'there'
34
35 response = await service_client.get('/v1/key-value?key=missing')
36 assert response.status == 404