1
2async def test_mongo(service_client, mongodb):
3 data = {
4 ('hello', 'ru', 'Привет'),
5 ('hello', 'en', 'hello'),
6 ('welcome', 'ru', 'Добро пожаловать'),
7 ('welcome', 'en', 'Welcome'),
8 }
9
10
11 translations_db = mongodb.translations
12 for key, lang, value in data:
13 response = await service_client.patch(
14 '/v1/translations',
15 params={'key': key, 'lang': lang, 'value': value},
16 )
17 assert response.status == 201
18
19
20 assert (
21 translations_db.find_one({'key': key, 'lang': lang})['value']
22 == value
23 )
24
25 response = await service_client.get('/v1/translations')
26 assert response.status_code == 200
27 assert 'application/json' in response.headers['Content-Type']
28 assert response.json()['content'] == {
29 'hello': {'en': 'hello', 'ru': 'Привет'},
30 'welcome': {'ru': 'Добро пожаловать', 'en': 'Welcome'},
31 }
32