This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
consumer-api/consumer_api/tests/consumers_view_test.py

30 lines
568 B
Python
Raw Normal View History

2020-05-08 20:36:45 +02:00
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