userver: samples/hello_service/testsuite/test_hello.py
Loading...
Searching...
No Matches
samples/hello_service/testsuite/test_hello.py
1# /// [Functional test]
2async def test_hello_base(service_client):
3 response = await service_client.get('/hello')
4 assert response.status == 200
5 assert 'text/plain' in response.headers['Content-Type']
6 assert response.text == 'Hello, unknown user!\n'
7 assert 'X-RequestId' not in response.headers.keys(), 'Unexpected header'
8
9 response = await service_client.get('/hello', params={'name': 'userver'})
10 assert response.status == 200
11 assert 'text/plain' in response.headers['Content-Type']
12 assert response.text == 'Hello, userver!\n'
13 # /// [Functional test]
14
15
16async def test_hello_head(service_client):
17 response = await service_client.request('HEAD', '/hello')
18 assert response.status == 200
19 assert 'text/plain' in response.headers['Content-Type']
20 assert response.text == ''
21 assert 'X-RequestId' not in response.headers.keys(), 'Unexpected header'
22
23
24async def test_wrong_method(service_client):
25 response = await service_client.request('KEK', '/hello')
26 assert response.status == 400
27 assert response.text == 'bad request'
28 assert 'X-YaRequestId' not in response.headers.keys(), 'Unexpected header'