Files
romm/backend/tests/endpoints/conftest.py
zurdi bd38eddd11 feat: add multi-file ROM fixture for testing and enhance soundtrack player functionality
- Introduced a new fixture `multi_file_rom` in `conftest.py` to create a ROM with multiple files for testing purposes.
- Updated `test_manual.py` and `test_soundtrack.py` to utilize the new fixture for testing manual uploads and soundtrack functionalities.
- Enhanced the audio tag extraction logic in `audio_tags.py` to handle oversized audio files and added a function to check allowed audio file extensions.
- Modified `nginx.py` to support inline file serving for audio files, allowing for better streaming capabilities.
- Improved error handling in the Vue components for soundtrack management, including user feedback for playback errors and metadata loading issues.
- Refactored the soundtrack player store to use local storage for volume and mute settings, simplifying state management.
- Added new localization strings for soundtrack player actions and error messages in both English (US and GB) locale files.
2026-04-20 08:33:35 +00:00

76 lines
1.8 KiB
Python

from datetime import timedelta
import pytest
from fastapi.testclient import TestClient
from main import app
from config import (
OAUTH_ACCESS_TOKEN_EXPIRE_SECONDS,
OAUTH_REFRESH_TOKEN_EXPIRE_SECONDS,
)
from handler.auth import oauth_handler
from handler.redis_handler import sync_cache
@pytest.fixture
def client():
with TestClient(app) as client:
yield client
@pytest.fixture(autouse=True)
def clear_cache():
sync_cache.flushall()
yield
sync_cache.flushall()
@pytest.fixture()
def access_token(admin_user): # noqa
data = {
"sub": admin_user.username,
"iss": "romm:oauth",
"scopes": " ".join(admin_user.oauth_scopes),
}
return oauth_handler.create_access_token(
data=data, expires_delta=timedelta(seconds=OAUTH_ACCESS_TOKEN_EXPIRE_SECONDS)
)
@pytest.fixture()
def refresh_token(admin_user): # noqa
data = {
"sub": admin_user.username,
"iss": "romm:oauth",
"scopes": " ".join(admin_user.oauth_scopes),
}
return oauth_handler.create_refresh_token(
data=data, expires_delta=timedelta(seconds=OAUTH_REFRESH_TOKEN_EXPIRE_SECONDS)
)
@pytest.fixture
def editor_access_token(editor_user): # noqa
return oauth_handler.create_access_token(
data={
"sub": editor_user.username,
"iss": "romm:oauth",
"scopes": " ".join(editor_user.oauth_scopes),
},
expires_delta=timedelta(seconds=OAUTH_ACCESS_TOKEN_EXPIRE_SECONDS),
)
@pytest.fixture
def viewer_access_token(viewer_user): # noqa
return oauth_handler.create_access_token(
data={
"sub": viewer_user.username,
"iss": "romm:oauth",
"scopes": " ".join(viewer_user.oauth_scopes),
},
expires_delta=timedelta(seconds=OAUTH_ACCESS_TOKEN_EXPIRE_SECONDS),
)