Skip to content

Commit

Permalink
Testing with pytest, router/api_v1 package tests, work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmdocua committed Sep 28, 2023
1 parent 063768b commit 44da189
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion repromon_app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_apikey_tester2: str = None
_apikey_tester3: str = None

_token_admin: str = None
_token_tester1: str = None
_token_tester2: str = None
_token_tester3: str = None
Expand Down Expand Up @@ -44,7 +45,8 @@ def init_db():
_apikey_tester2 = svc.get_user_apikey("tester2").apikey
_apikey_tester3 = svc.get_user_apikey("tester3").apikey

global _token_tester1, _token_tester2, _token_tester3
global _token_admin, _token_tester1, _token_tester2, _token_tester3
_token_admin = svc.create_access_token("admin", 60 * 60).access_token
_token_tester1 = svc.create_access_token("tester1", 60 * 60).access_token
_token_tester2 = svc.create_access_token("tester2", 60 * 60).access_token
_token_tester3 = svc.create_access_token("tester3", 60 * 60).access_token
Expand Down Expand Up @@ -74,6 +76,30 @@ def apikey_tester3() -> str:
return _apikey_tester3


@pytest.fixture
def apikey_tester1_headers() -> dict:
global _apikey_tester1
return {
"X-Api-Key": _apikey_tester1
}


@pytest.fixture
def apikey_tester2_headers() -> dict:
global _apikey_tester2
return {
"X-Api-Key": _apikey_tester2
}


@pytest.fixture
def apikey_tester3_headers() -> dict:
global _apikey_tester3
return {
"X-Api-Key": _apikey_tester3
}


@pytest.fixture
def base_url() -> str:
return f"https://{app_settings().WEB_HOST}:{str(app_settings().WEB_PORT)}"
Expand All @@ -87,6 +113,14 @@ def fastapi_app() -> FastAPI:
return _fastapi_app


@pytest.fixture
def oauth2_admin_headers() -> dict:
global _token_admin
return {
"Authorization": f"Bearer {_token_admin}"
}


@pytest.fixture
def oauth2_tester1_headers() -> dict:
global _token_tester1
Expand Down

0 comments on commit 44da189

Please sign in to comment.