userver: /data/code/userver/libraries/easy/samples/4_custom_dependency/testsuite/test_basic.py Source File
Loading...
Searching...
No Matches
test_basic.py
1async def test_log_action(service_client, pgsql, mockserver):
2 @mockserver.handler('/v1/action')
3 def _mock(request):
4 assert (
5 request.get_data() == b'test_1'
6 ), f'Actual data is {request.get_data()}'
7 return mockserver.make_response()
8
9 response = await service_client.post('/log?action=test_1')
10 assert response.status == 200
11
12 # '0_db_schema.sql' is created by `db_dump_schema_path` fixture, so the database is '0_db_schema'
13 cursor = pgsql['0_db_schema'].cursor()
14 cursor.execute('SELECT action FROM events_table WHERE id=1')
15 result = cursor.fetchall()
16 assert len(result) == 1
17 assert result[0][0] == 'test_1'