30 lines
568 B
Python
30 lines
568 B
Python
|
import pytest
|
||
|
|
||
|
from flask import current_app
|
||
|
|
||
|
|
||
|
@pytest.fixture
|
||
|
def client():
|
||
|
current_app.config["TESTING"] = True
|
||
|
|
||
|
with current_app.test_client() as client:
|
||
|
yield client
|
||
|
|
||
|
|
||
|
def test_access_denied(client):
|
||
|
r = client.get('/api/user')
|
||
|
|
||
|
assert r.status_code == 401
|
||
|
|
||
|
|
||
|
def test_access_denied2(client):
|
||
|
r = client.get('/api/user', headers = { "Authorization": "invalidkey" })
|
||
|
|
||
|
assert r.status_code == 401
|
||
|
|
||
|
|
||
|
def test_empty_database(client):
|
||
|
r = client.get('/api/user', headers = { "Authorization": "testkey" })
|
||
|
|
||
|
assert len(r.json) == 0
|