mirror of https://gitlab.com/litecord/litecord.git
tests: add basic test
This commit is contained in:
parent
599989f32e
commit
7b75202311
2
Pipfile
2
Pipfile
|
|
@ -8,7 +8,7 @@ bcrypt = "==3.1.4"
|
||||||
itsdangerous = "==0.24"
|
itsdangerous = "==0.24"
|
||||||
asyncpg = "==0.16.0"
|
asyncpg = "==0.16.0"
|
||||||
websockets = "==6.0"
|
websockets = "==6.0"
|
||||||
Quart = "==0.6.4"
|
Quart = "==0.6.9"
|
||||||
Earl-ETF = "==2.1.2"
|
Earl-ETF = "==2.1.2"
|
||||||
logbook = "*"
|
logbook = "*"
|
||||||
Cerberus = "==1.2"
|
Cerberus = "==1.2"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "79cac6eb8d68f62bc18e7614f30098d2d4e5acdfcf4170cc1f95bd3abc6bea14"
|
"sha256": "fc9b7ad7152bf6e26291b295af92aa0a45e5140d7c87c543d769642b0c7c4919"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
@ -355,11 +355,11 @@
|
||||||
},
|
},
|
||||||
"quart": {
|
"quart": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:06ac9cfcc0387b596b1d81aeffd5ade1d48186d435760bbf43eeb4981d7c936c",
|
"sha256:cbb776a94168234a019ab432db86025d0b4dfe02d26378f7e618c7c2a9996ebe",
|
||||||
"sha256:419fcaf62052a45a0534e9f5ce94ca27ff5ba5577a1a8d41f561e9c839378884"
|
"sha256:d4e5fc3aed22f3a50be780e62cf35dfb4ba1c947692b86ab8b6744e915413786"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==0.6.4"
|
"version": "==0.6.9"
|
||||||
},
|
},
|
||||||
"six": {
|
"six": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
|
||||||
3
run.py
3
run.py
|
|
@ -92,7 +92,6 @@ for bp, suffix in bps.items():
|
||||||
suffix = suffix or ''
|
suffix = suffix or ''
|
||||||
app.register_blueprint(bp, url_prefix=f'/api/v6{suffix}')
|
app.register_blueprint(bp, url_prefix=f'/api/v6{suffix}')
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
async def app_before_request():
|
async def app_before_request():
|
||||||
await ratelimit_handler()
|
await ratelimit_handler()
|
||||||
|
|
@ -188,6 +187,7 @@ async def app_before_serving():
|
||||||
ws_future = websockets.serve(_wrapper, host, port)
|
ws_future = websockets.serve(_wrapper, host, port)
|
||||||
|
|
||||||
await ws_future
|
await ws_future
|
||||||
|
log.info('started')
|
||||||
|
|
||||||
|
|
||||||
@app.after_serving
|
@app.after_serving
|
||||||
|
|
@ -236,4 +236,5 @@ async def handle_500(err):
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
async def index():
|
async def index():
|
||||||
|
"""sample index page."""
|
||||||
return 'hewwo'
|
return 'hewwo'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
import asyncio
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
from run import make_app, init_app_db, init_app_managers, set_blueprints
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name='app')
|
||||||
|
def _test_app():
|
||||||
|
app = make_app()
|
||||||
|
set_blueprints(app)
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(init_app_db(app))
|
||||||
|
init_app_managers(app)
|
||||||
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name='test_cli')
|
||||||
|
def _test_cli(app):
|
||||||
|
return app.test_client()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_index(test_cli):
|
||||||
|
resp = await test_cli.get('/')
|
||||||
|
assert resp.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_gw(test_cli):
|
||||||
|
resp = await test_cli.get('/api/v6/gateway/')
|
||||||
|
assert resp.status_code == 200
|
||||||
|
rjson = await resp.json()
|
||||||
|
assert isinstance(rjson, dict)
|
||||||
|
assert 'gateway' in rjson
|
||||||
|
assert isinstance(rjson['gateway'], str)
|
||||||
Loading…
Reference in New Issue