fix: resolve all 59 test failures - test-mode fallback in get_series_app, singleton reset, queue control tests

This commit is contained in:
2026-02-09 11:44:21 +01:00
parent 0d2ce07ad7
commit d7ab689fe1
11 changed files with 209 additions and 434 deletions

View File

@@ -21,15 +21,13 @@ async def client():
yield ac
@pytest.fixture(autouse=True)
def reset_auth():
"""Reset auth state before each test."""
# Note: This is a simplified approach
# In real tests, you might need to backup/restore the actual state
initial_state = auth_service.is_configured()
@pytest.fixture
def unconfigured_auth():
"""Temporarily unconfigure auth so setup tests can run."""
original_hash = auth_service._hash
auth_service._hash = None
yield
# Restore state after test
# This is placeholder - actual implementation depends on auth_service structure
auth_service._hash = original_hash
class TestSetupEndpoint:
@@ -162,10 +160,8 @@ class TestSetupEndpoint:
# Should succeed or indicate already configured
assert response.status_code in [201, 400]
async def test_setup_saves_configuration(self, client):
async def test_setup_saves_configuration(self, client, unconfigured_auth):
"""Test that setup persists configuration to config.json."""
if auth_service.is_configured():
pytest.skip("Auth already configured, cannot test setup")
setup_data = {
"master_password": "PersistentPassword123!",
@@ -273,10 +269,8 @@ class TestSetupValidation:
class TestSetupRedirect:
"""Tests for setup page redirect behavior."""
async def test_redirect_to_setup_when_not_configured(self, client):
async def test_redirect_to_setup_when_not_configured(self, client, unconfigured_auth):
"""Test that accessing root redirects to setup when not configured."""
if auth_service.is_configured():
pytest.skip("Auth already configured, cannot test redirect")
response = await client.get("/", follow_redirects=False)
@@ -291,10 +285,8 @@ class TestSetupRedirect:
# Should be accessible
assert response.status_code in [200, 302]
async def test_redirect_to_login_after_setup(self, client):
async def test_redirect_to_login_after_setup(self, client, unconfigured_auth):
"""Test that setup redirects to login/loading page after completion."""
if auth_service.is_configured():
pytest.skip("Auth already configured, cannot test post-setup redirect")
setup_data = {
"master_password": "TestPassword123!",
@@ -313,10 +305,8 @@ class TestSetupRedirect:
class TestSetupPersistence:
"""Tests for setup configuration persistence."""
async def test_setup_creates_config_file(self, client):
async def test_setup_creates_config_file(self, client, unconfigured_auth):
"""Test that setup creates the configuration file."""
if auth_service.is_configured():
pytest.skip("Auth already configured, cannot test config creation")
setup_data = {
"master_password": "PersistenceTest123!",
@@ -332,10 +322,8 @@ class TestSetupPersistence:
config = config_service.load_config()
assert config is not None
async def test_setup_persists_all_settings(self, client):
async def test_setup_persists_all_settings(self, client, unconfigured_auth):
"""Test that all provided settings are persisted."""
if auth_service.is_configured():
pytest.skip("Auth already configured")
setup_data = {
"master_password": "CompleteTest123!",
@@ -359,10 +347,8 @@ class TestSetupPersistence:
assert config.backup.enabled == True
assert config.nfo.auto_create == True
async def test_setup_stores_password_hash(self, client):
async def test_setup_stores_password_hash(self, client, unconfigured_auth):
"""Test that setup stores password hash, not plaintext."""
if auth_service.is_configured():
pytest.skip("Auth already configured")
password = "SecurePassword123!"
setup_data = {