userver: samples/static_service/testsuite/test_static.py
Loading...
Searching...
No Matches
samples/static_service/testsuite/test_static.py
1# [Functional test]
2import pytest
3
4
5@pytest.mark.parametrize('path', ['/index.html', '/'])
6async def test_file(service_client, service_source_dir, path):
7 response = await service_client.get(path)
8 assert response.status == 200
9 assert response.headers['Content-Type'] == 'text/html'
10 assert response.headers['Expires'] == '600'
11 file = service_source_dir.joinpath('public') / 'index.html'
12 assert response.content.decode() == file.open().read()
13 # [Functional test]
14
15
16async def test_file_not_found(service_client):
17 response = await service_client.get('/file.not')
18 assert response.status == 404
19 assert b'File not found' in response.content