2020-07-10 12:58:53 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import pytest
|
|
|
|
from starlette.authentication import UnauthenticatedUser
|
|
|
|
from starlette.testclient import TestClient
|
2020-09-25 01:06:21 +02:00
|
|
|
import json
|
2020-07-10 12:58:53 +02:00
|
|
|
|
|
|
|
|
2021-06-17 18:53:23 +02:00
|
|
|
def test_current_user(project_runner, application_debug):
|
|
|
|
c = TestClient(application_debug)
|
2020-09-28 17:22:27 +02:00
|
|
|
r = c.get('/halfapi/current_user')
|
2020-09-25 01:06:21 +02:00
|
|
|
assert r.status_code == 200
|
2021-03-12 18:59:30 +01:00
|
|
|
|
2021-06-17 18:53:23 +02:00
|
|
|
def test_log(application_debug):
|
|
|
|
c = TestClient(application_debug)
|
2021-03-12 18:59:30 +01:00
|
|
|
r = c.get('/halfapi/log')
|
|
|
|
assert r.status_code == 200
|
|
|
|
|
2021-06-17 18:53:23 +02:00
|
|
|
def test_error(application_debug):
|
|
|
|
c = TestClient(application_debug)
|
2021-03-12 18:59:30 +01:00
|
|
|
r = c.get('/halfapi/error/400')
|
|
|
|
assert r.status_code == 400
|
|
|
|
r = c.get('/halfapi/error/404')
|
|
|
|
assert r.status_code == 404
|
|
|
|
r = c.get('/halfapi/error/500')
|
|
|
|
assert r.status_code == 500
|
|
|
|
|
2021-06-17 18:53:23 +02:00
|
|
|
def test_exception(application_debug):
|
|
|
|
c = TestClient(application_debug)
|
2021-03-12 18:59:30 +01:00
|
|
|
try:
|
|
|
|
r = c.get('/halfapi/exception')
|
|
|
|
assert r.status_code == 500
|
|
|
|
except Exception:
|
|
|
|
print('exception')
|