@@ -33,5 +33,7 @@ services:
|
||||
image: donkie/spoolman-tester:latest
|
||||
volumes:
|
||||
- ./tests:/tester/tests
|
||||
environment:
|
||||
- DB_TYPE=cockroachdb
|
||||
depends_on:
|
||||
- spoolman
|
||||
|
||||
@@ -37,5 +37,7 @@ services:
|
||||
image: donkie/spoolman-tester:latest
|
||||
volumes:
|
||||
- ./tests:/tester/tests
|
||||
environment:
|
||||
- DB_TYPE=mysql
|
||||
depends_on:
|
||||
- spoolman
|
||||
|
||||
@@ -20,5 +20,7 @@ services:
|
||||
image: donkie/spoolman-tester:latest
|
||||
volumes:
|
||||
- ./tests:/tester/tests
|
||||
environment:
|
||||
- DB_TYPE=postgres
|
||||
depends_on:
|
||||
- spoolman
|
||||
|
||||
@@ -8,5 +8,7 @@ services:
|
||||
image: donkie/spoolman-tester:latest
|
||||
volumes:
|
||||
- ./tests:/tester/tests
|
||||
environment:
|
||||
- DB_TYPE=sqlite
|
||||
depends_on:
|
||||
- spoolman
|
||||
|
||||
@@ -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."""
|
||||
|
||||
18
tests_integration/tests/test_backup.py
Normal file
18
tests_integration/tests/test_backup.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""Integration tests for the Vendor API endpoint."""
|
||||
|
||||
import httpx
|
||||
|
||||
from .conftest import DbType, get_db_type
|
||||
|
||||
URL = "http://spoolman:8000"
|
||||
|
||||
|
||||
def test_backup():
|
||||
"""Test triggering an automatic database backup."""
|
||||
if get_db_type() != DbType.SQLITE:
|
||||
return
|
||||
|
||||
# Trigger backup
|
||||
result = httpx.post(f"{URL}/api/v1/backup")
|
||||
result.raise_for_status()
|
||||
assert result.json()["success"] is True
|
||||
Reference in New Issue
Block a user