mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-04-09 11:25:40 +00:00
setup coverage
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
||||
import aiohttp
|
||||
import nio
|
||||
|
||||
from utils import MATRIX_ID, MATRIX_PW, MATRIX_URL, AbstractBotTest
|
||||
from .utils import BOT_URL, MATRIX_ID, MATRIX_PW, MATRIX_URL, AbstractBotTest
|
||||
|
||||
KEY = os.environ['API_KEY']
|
||||
|
||||
@@ -16,13 +16,13 @@ class BotTest(AbstractBotTest):
|
||||
async def test_errors(self):
|
||||
"""Check the bot's error paths."""
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get('http://bot:4785') as response:
|
||||
async with session.get(BOT_URL) as response:
|
||||
self.assertEqual(await response.json(), {'status': 400, 'ret': 'Invalid JSON'})
|
||||
async with session.post('http://bot:4785', data=json.dumps({'toto': 3})) as response:
|
||||
async with session.post(BOT_URL, data=json.dumps({'toto': 3})) as response:
|
||||
self.assertEqual(await response.json(), {'status': 400, 'ret': 'Missing text and/or API key property'})
|
||||
async with session.post('http://bot:4785', data=json.dumps({'text': 3, 'key': None})) as response:
|
||||
async with session.post(BOT_URL, data=json.dumps({'text': 3, 'key': None})) as response:
|
||||
self.assertEqual(await response.json(), {'status': 401, 'ret': 'Invalid API key'})
|
||||
async with session.post('http://bot:4785', data=json.dumps({'text': 3, 'key': KEY})) as response:
|
||||
async with session.post(BOT_URL, data=json.dumps({'text': 3, 'key': KEY})) as response:
|
||||
# TODO: we are not sending to a real room, so this should not be "OK"
|
||||
self.assertEqual(await response.json(), {'status': 200, 'ret': 'OK'})
|
||||
|
||||
@@ -36,7 +36,7 @@ class BotTest(AbstractBotTest):
|
||||
|
||||
room = await client.room_create()
|
||||
|
||||
url = f'http://bot:4785/{room.room_id}'
|
||||
url = f'{BOT_URL}/{room.room_id}'
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(url, data=json.dumps({'text': text, 'key': KEY})) as response:
|
||||
self.assertEqual(await response.json(), {'status': 200, 'ret': 'OK'})
|
||||
|
||||
Reference in New Issue
Block a user