42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from tenbackward.config import Config
|
|
|
|
|
|
@pytest.fixture()
|
|
def env_setup(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""Provide a fully populated environment for Config success paths.
|
|
|
|
Tests that exercise the missing-required-key path should call
|
|
`monkeypatch.delenv(...)` explicitly.
|
|
"""
|
|
monkeypatch.setenv("MASTODON_BASE_URL", "https://mastodon.example")
|
|
monkeypatch.setenv("MASTODON_ACCESS_TOKEN", "test-token")
|
|
monkeypatch.setenv("MASTODON_VISIBILITY", "public")
|
|
monkeypatch.setenv("SITE_URL", "https://blog.example.com")
|
|
monkeypatch.setenv("HASHTAGS", "#throwback,#10backward")
|
|
monkeypatch.setenv("THROWBACK_PREFIX", "Throwback:")
|
|
monkeypatch.setenv("MAX_RETRIES", "3")
|
|
monkeypatch.setenv("RUN_AT", "09:00")
|
|
monkeypatch.setenv("TZ", "Europe/Berlin")
|
|
|
|
|
|
@pytest.fixture()
|
|
def data_dir(tmp_path: Path) -> Path:
|
|
return tmp_path / "data"
|
|
|
|
|
|
@pytest.fixture()
|
|
def full_config(env_setup, data_dir) -> Config:
|
|
"""Build a Config object that points at an isolated data dir."""
|
|
from tenbackward.config import load_config
|
|
|
|
import os
|
|
|
|
os.environ["DATA_DIR"] = str(data_dir)
|
|
return load_config()
|