Files
dylan 06a0a33a3a Update tests structure. (#68)
* Update tests structure.
* Unit tests use the test database
* Add function for creating database engine and session.
2023-05-23 17:52:34 +08:00

29 lines
719 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
sys.path.append('../../')
import pytest
from typing import Generator, Dict
from starlette.testclient import TestClient
from backend.app.main import app
from backend.app.tests.utils.get_headers import get_token_headers
from backend.app.database.db_mysql import get_db
from backend.app.tests.utils.db_mysql import override_get_db
app.dependency_overrides[get_db] = override_get_db
@pytest.fixture(scope='module')
def client() -> Generator:
with TestClient(app) as c:
yield c
@pytest.fixture(scope='module')
def token_headers(client: TestClient) -> Dict[str, str]:
return get_token_headers(client=client, username='test', password='test')