refactor: remove duplicate fixtures and add SQLite support
Task 2.5: Remove duplicate fixtures from integration tests - test_auth_api.py, test_auth_services.py, test_models.py - test_projects_api.py, test_seed.py, test_users_api.py - Fix npytest typos in all test files Task 3.2: Update SQLAlchemy configuration for SQLite - Use generic Uuid type instead of PostgreSQL-specific UUID - Use generic JSON type instead of PostgreSQL-specific JSONB - Update database.py to handle SQLite connection args Unit tests now run without PostgreSQL (5/8 passing)
This commit is contained in:
@@ -14,18 +14,6 @@ from src.models import Base
|
||||
from src.models.user import User
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def configure_local_database(monkeypatch) -> None:
|
||||
local_url = build_database_url(
|
||||
user="headquarter",
|
||||
password="headquarter",
|
||||
host="localhost",
|
||||
port=5432,
|
||||
database="headquarter",
|
||||
)
|
||||
monkeypatch.setenv("DATABASE_URL", local_url)
|
||||
|
||||
|
||||
def _prepare_users_test_db() -> None:
|
||||
async def _run() -> None:
|
||||
engine = create_async_engine(
|
||||
@@ -99,8 +87,7 @@ def _create_auth_cookie(user_id: str) -> str:
|
||||
)
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_profile_returns_401_without_cookie() -> None:
|
||||
_prepare_users_test_db()
|
||||
app = _load_app()
|
||||
@@ -111,8 +98,7 @@ def test_get_profile_returns_401_without_cookie() -> None:
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_profile_returns_user_data() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -130,8 +116,7 @@ def test_get_profile_returns_user_data() -> None:
|
||||
assert data["avatar_url"] is None
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_update_profile_changes_name_and_email() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -148,8 +133,7 @@ def test_update_profile_changes_name_and_email() -> None:
|
||||
assert data["email"] == "updated@headquarter.local"
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_update_profile_rejects_empty_name() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -163,8 +147,7 @@ def test_update_profile_rejects_empty_name() -> None:
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_update_profile_rejects_invalid_email() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -178,8 +161,7 @@ def test_update_profile_rejects_invalid_email() -> None:
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_upload_avatar_updates_avatar_url() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -202,8 +184,7 @@ def test_upload_avatar_updates_avatar_url() -> None:
|
||||
assert data["avatar_url"].startswith("/uploads/avatars/")
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_upload_avatar_rejects_invalid_file_type() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
@@ -221,8 +202,7 @@ def test_upload_avatar_rejects_invalid_file_type() -> None:
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
n@pytest.mark.integration
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_upload_avatar_rejects_oversized_file() -> None:
|
||||
_prepare_users_test_db()
|
||||
user_id = "7f4b7ad8-c4ce-4d1b-8c83-7ce0f4f66dfb"
|
||||
|
||||
Reference in New Issue
Block a user