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-10-04 20:12:43 +02:00
|
|
|
def test_whoami(project_runner, application_debug):
|
|
|
|
# @TODO : test with fake login
|
2021-06-17 18:53:23 +02:00
|
|
|
c = TestClient(application_debug)
|
2021-10-04 20:12:43 +02:00
|
|
|
r = c.get('/halfapi/whoami')
|
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-11-30 14:40:07 +01:00
|
|
|
@pytest.mark.skip
|
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')
|