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