1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00

🚧 WIP testing stuff

This commit is contained in:
Stefano Pigozzi 2021-05-07 21:22:45 +02:00
parent 7a4e99c4f1
commit 3529af69f5
Signed by untrusted user who does not match committer: steffo
GPG key ID: 6965406171929D01
3 changed files with 20 additions and 4 deletions

View file

@ -4,4 +4,4 @@ Pytest configuration file.
Import global fixtures here.
"""
from fixtures.flask_client import flask_client
from fixtures.flask_client import flask_client, access_token

View file

@ -35,3 +35,18 @@ def flask_client():
# Teardown schema
with app.app_context():
ext.engine.execute(f"""DROP SCHEMA "{uniq_schema}" CASCADE;""")
@pytest.fixture()
def access_token(flask_client):
response = flask_client.post("/api/v1/login", json={
"username": "admin",
"password": "password"
})
assert response.json is not None
assert "result" in response.json
assert response.json["result"] == "success"
assert "data" in response.json
data = response.json["data"]
assert "access_token" in data
return data["access_token"]

View file

@ -1,9 +1,10 @@
import pytest
from flask.testing import Client
from nest_backend.test.fixtures import flask_client
# noinspection PyShadowingNames
def test_doa(flask_client: Client):
response = flask_client.get("/doa")
def test_doa(flask_client: Client, access_token: str):
response = flask_client.get("/doa", headers={
"Authorization": f"Bearer {access_token}",
})
assert b"If you see this, the server is fine." in response.data