Skip to content

Commit

Permalink
Testing with pytest, router/admin 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 79752aa commit 3bc9dd4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions repromon_app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from httpx import BasicAuth

from repromon_app.config import app_config, app_config_init, app_settings
from repromon_app.db import db_init
Expand Down Expand Up @@ -41,6 +42,11 @@ def init_db():
yield


@pytest.fixture
def admin_basic_auth() -> BasicAuth:
return BasicAuth("admin", app_settings().INITIAL_ADMIN_PASSWORD)


@pytest.fixture
def apikey_tester1() -> str:
global _apikey_tester1
Expand Down
15 changes: 15 additions & 0 deletions repromon_app/tests/router/test_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging

from fastapi.testclient import TestClient

logger = logging.getLogger(__name__)
logger.debug(f"name={__name__}")


def test_admin_root(
test_client: TestClient,
admin_basic_auth
):
response = test_client.get("/admin", auth=admin_basic_auth)
assert response.status_code == 200
assert "ReproMon Admin Home" in response.text

0 comments on commit 3bc9dd4

Please sign in to comment.