import pytest from app import create_app def test_testing_configuration_is_isolated(): app = create_app("testing") assert app.config["TESTING"] is True assert app.config["SQLALCHEMY_DATABASE_URI"] == "sqlite:///:memory:" assert app.config["SESSION_COOKIE_HTTPONLY"] is True assert app.config["SESSION_COOKIE_SAMESITE"] == "Lax" def test_unknown_configuration_fails_clearly(): with pytest.raises(ValueError, match="Unknown configuration"): create_app("unknown") def test_csrf_is_required_outside_testing(): app = create_app("development") client = app.test_client() response = client.post( "/auth/register", data={ "username": "steady_user", "email": "person@example.com", "password": "a calm secure password", "confirm_password": "a calm secure password", }, ) assert response.status_code == 400