Added automatic nightly SQLite backups

Resolves #22
This commit is contained in:
Donkie
2023-07-04 14:59:05 +02:00
parent 51783afe92
commit f24b9610e8
13 changed files with 221 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
"""Test fixtures for integration tests."""
import os
import time
from enum import Enum
from typing import Any
import httpx
@@ -11,6 +13,27 @@ TIMEOUT = 10
URL = "http://spoolman:8000"
class DbType(str, Enum):
"""Enum for database types."""
SQLITE = "sqlite"
POSTGRES = "postgres"
MYSQL = "mysql"
COCKROACHDB = "cockroachdb"
def get_db_type() -> DbType:
"""Return the database type from environment variables."""
env_db_type = os.environ.get("DB_TYPE")
if env_db_type is None:
raise RuntimeError("DB_TYPE environment variable not set")
try:
db_type = DbType(env_db_type)
except ValueError as e:
raise RuntimeError(f"Unknown database type: {env_db_type}") from e
return db_type
@pytest.fixture(scope="session", autouse=True)
def _wait_for_server(): # noqa: ANN202
"""Wait for the server to start up."""