mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-01 09:37:12 +09:00
- Accept 'test' as valid environment in config tests (pytest sets ENVIRONMENT=test) - Add job status validation to preview-video endpoint (must be in review state) - Update emulator integration test to expect 400 for non-review jobs
69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
"""
|
|
Extended tests for config.py to improve coverage.
|
|
"""
|
|
import pytest
|
|
import os
|
|
from unittest.mock import patch
|
|
|
|
|
|
class TestSettingsConfiguration:
|
|
"""Tests for Settings configuration."""
|
|
|
|
def test_settings_class_exists(self):
|
|
"""Test Settings class exists."""
|
|
from backend.config import Settings
|
|
assert Settings is not None
|
|
|
|
def test_settings_loads_defaults(self):
|
|
"""Test Settings loads default values."""
|
|
from backend.config import Settings
|
|
settings = Settings()
|
|
assert settings is not None
|
|
|
|
def test_gcs_bucket_name_from_env(self):
|
|
"""Test GCS bucket name from environment."""
|
|
with patch.dict(os.environ, {'GCS_BUCKET_NAME': 'test-bucket'}):
|
|
from backend.config import Settings
|
|
settings = Settings()
|
|
assert settings.gcs_bucket_name == 'test-bucket'
|
|
|
|
def test_firestore_collection_from_env(self):
|
|
"""Test Firestore collection from environment."""
|
|
with patch.dict(os.environ, {'FIRESTORE_COLLECTION': 'test-jobs'}):
|
|
from backend.config import Settings
|
|
settings = Settings()
|
|
assert settings.firestore_collection == 'test-jobs'
|
|
|
|
def test_environment_setting(self):
|
|
"""Test environment setting."""
|
|
from backend.config import Settings
|
|
settings = Settings()
|
|
# Accept 'test' as well since pytest may set ENVIRONMENT=test
|
|
assert settings.environment in ['development', 'production', 'testing', 'test']
|
|
|
|
def test_google_cloud_project(self):
|
|
"""Test Google Cloud project setting."""
|
|
with patch.dict(os.environ, {'GOOGLE_CLOUD_PROJECT': 'test-project'}):
|
|
from backend.config import Settings
|
|
settings = Settings()
|
|
# Should either use the env var or have a default
|
|
|
|
|
|
class TestGetSettings:
|
|
"""Tests for get_settings function."""
|
|
|
|
def test_get_settings_returns_settings(self):
|
|
"""Test get_settings returns Settings instance."""
|
|
from backend.config import get_settings
|
|
settings = get_settings()
|
|
assert settings is not None
|
|
|
|
def test_get_settings_returns_same_instance(self):
|
|
"""Test get_settings returns cached instance."""
|
|
from backend.config import get_settings
|
|
settings1 = get_settings()
|
|
settings2 = get_settings()
|
|
# Should be same cached instance
|
|
assert settings1 is settings2
|
|
|