diff --git a/tests/test_invite_table_route.py b/tests/test_invite_table_route.py index 5282eba3..2bb9040a 100644 --- a/tests/test_invite_table_route.py +++ b/tests/test_invite_table_route.py @@ -18,6 +18,7 @@ def admin_user(app): """Create an admin account for authenticated requests.""" with app.app_context(): created = False + previous_hash = None admin = AdminAccount.query.filter_by(username="testadmin").first() if not admin: admin = AdminAccount(username="testadmin") @@ -25,10 +26,20 @@ def admin_user(app): db.session.add(admin) db.session.commit() created = True + else: + previous_hash = admin.password_hash + admin.set_password("TestPass123") + db.session.commit() yield admin if created: db.session.delete(admin) db.session.commit() + elif previous_hash is not None: + # Restore the original password hash so other tests keep their expectations + admin = AdminAccount.query.filter_by(username="testadmin").first() + if admin: + admin.password_hash = previous_hash + db.session.commit() @pytest.fixture diff --git a/tests/test_library_scanning.py b/tests/test_library_scanning.py index 33515610..974a0cff 100644 --- a/tests/test_library_scanning.py +++ b/tests/test_library_scanning.py @@ -8,7 +8,7 @@ from app.models import AdminAccount, ApiKey, Library, MediaServer, Settings @pytest.fixture -def api_key(app): +def api_key(app, session): """Create a test API key.""" with app.app_context(): # Create admin account if it doesn't exist @@ -45,7 +45,7 @@ def api_key(app): @pytest.fixture -def test_server(app): +def test_server(app, session): """Create a test media server.""" with app.app_context(): # Create admin account if it doesn't exist