20 lines
758 B
Python
20 lines
758 B
Python
import pytest
|
|||
|
|
from cryptography.fernet import Fernet
|
||
|
|
|
||
|
|
from app import db
|
||
|
|
from app.config import get_settings
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(autouse=True)
|
||
|
|
def env(tmp_path, monkeypatch):
|
||
|
|
monkeypatch.setenv("DATABASE_URL", f"sqlite:///{tmp_path}/test.db")
|
||
|
|
monkeypatch.setenv("SECRET_KEY", Fernet.generate_key().decode())
|
||
|
|
monkeypatch.setenv("API_TOKEN", "test-token")
|
||
|
|
monkeypatch.setenv("S3_BUCKET", "test-bucket")
|
||
|
|
monkeypatch.setenv("POLL_INTERVAL", "0") # фоновый опрос в тестах выключен
|
||
|
|
monkeypatch.setenv("ADMIN_USER", "admin") # не зависеть от реального .env
|
||
|
|
monkeypatch.setenv("ADMIN_PASSWORD", "pw")
|
||
|
|
get_settings.cache_clear()
|
||
|
|
db.init_db()
|
||
|
|
yield
|
||
|
|
get_settings.cache_clear()
|