[tests] Fix formatting

This commit is contained in:
Cathy Hu 2020-09-12 18:42:52 +02:00
parent 014114a8db
commit 1a8071d8d6
2 changed files with 26 additions and 6 deletions

View file

@ -19,7 +19,13 @@ def disable_spawner(monkeypatch):
@mark.parametrize('body', [{'api_token': 'string', 'welcome_message': 'string'}]) @mark.parametrize('body', [{'api_token': 'string', 'welcome_message': 'string'}])
def test_telegram_create_bot( def test_telegram_create_bot(
event_loop, client, disable_spawner, hood_id, auth_header, monkeypatch, body, event_loop,
client,
disable_spawner,
hood_id,
auth_header,
monkeypatch,
body,
): ):
def check_token_mock(token): def check_token_mock(token):
return True return True
@ -27,7 +33,9 @@ def test_telegram_create_bot(
monkeypatch.setattr(telegram.webapi, 'check_token', check_token_mock) monkeypatch.setattr(telegram.webapi, 'check_token', check_token_mock)
response = client.post( response = client.post(
f'/api/hoods/{hood_id}/telegram/', json=body, headers=auth_header, f'/api/hoods/{hood_id}/telegram/',
json=body,
headers=auth_header,
) )
assert response.status_code == status.HTTP_201_CREATED assert response.status_code == status.HTTP_201_CREATED
bot_id = response.json()['id'] bot_id = response.json()['id']
@ -44,10 +52,18 @@ def test_telegram_create_bot(
@mark.parametrize('body', [{'api_token': 'string', 'welcome_message': 'string'}]) @mark.parametrize('body', [{'api_token': 'string', 'welcome_message': 'string'}])
def test_telegram_invalid_api_token( def test_telegram_invalid_api_token(
event_loop, client, disable_spawner, hood_id, auth_header, monkeypatch, body, event_loop,
client,
disable_spawner,
hood_id,
auth_header,
monkeypatch,
body,
): ):
response = client.post( response = client.post(
f'/api/hoods/{hood_id}/telegram/', json=body, headers=auth_header, f'/api/hoods/{hood_id}/telegram/',
json=body,
headers=auth_header,
) )
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY

View file

@ -11,12 +11,16 @@ def test_telegram_get_bots(client, auth_header, event_loop, hood_id):
hood = event_loop.run_until_complete(Hood.objects.get(id=hood_id)) hood = event_loop.run_until_complete(Hood.objects.get(id=hood_id))
telegram0 = event_loop.run_until_complete( telegram0 = event_loop.run_until_complete(
Telegram.objects.create( Telegram.objects.create(
hood=hood, api_token='api_token123', welcome_message='welcome_message123', hood=hood,
api_token='api_token123',
welcome_message='welcome_message123',
) )
) )
telegram1 = event_loop.run_until_complete( telegram1 = event_loop.run_until_complete(
Telegram.objects.create( Telegram.objects.create(
hood=hood, api_token='api_token456', welcome_message='welcome_message123', hood=hood,
api_token='api_token456',
welcome_message='welcome_message123',
) )
) )
response = client.get( response = client.get(