mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 06:24:19 +00:00
🚧 WIP testing stuff
This commit is contained in:
parent
7a4e99c4f1
commit
3529af69f5
3 changed files with 20 additions and 4 deletions
|
@ -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
|
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue