feat: add appointments, campaigns, admin, storage, tests and various updates

- Add new routers: admin, appointments, campaigns
- Add storage service and logging config
- Add migrations directory and test suite with pytest config
- Add supabase_migration_features.sql
- Update models, dependencies, config, and existing routers
- Remove whatsapp_service (deleted)
- Update pyproject.toml and uv.lock dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
belviskhoremk
2026-04-03 09:11:58 +00:00
parent 9dccc83293
commit 92d4c2fc5e
51 changed files with 7076 additions and 515 deletions

77
tests/conftest.py Normal file
View File

@@ -0,0 +1,77 @@
"""
Test fixtures for Contexta backend.
Uses unittest.mock to avoid hitting real Supabase/Qdrant in unit tests.
"""
import pytest
from unittest.mock import MagicMock, patch, AsyncMock
from fastapi.testclient import TestClient
@pytest.fixture
def client():
"""FastAPI test client. Patches Supabase and Qdrant at module level."""
with patch("app.database.get_supabase") as mock_sb, \
patch("app.services.vector_store.vector_store") as mock_vs:
mock_sb.return_value = _make_supabase_mock()
mock_vs.create_collection = MagicMock()
mock_vs.delete_collection = MagicMock()
mock_vs.search = MagicMock(return_value=[])
from app.main import app
yield TestClient(app)
@pytest.fixture
def supabase_mock():
"""Standalone Supabase mock for direct use."""
return _make_supabase_mock()
@pytest.fixture
def auth_headers():
"""Mock auth headers (token is verified by patching get_current_user)."""
return {"Authorization": "Bearer test-token"}
@pytest.fixture
def mock_current_user():
"""A mock Supabase auth user object."""
user = MagicMock()
user.id = "test-user-id"
user.email = "test@example.com"
return user
@pytest.fixture
def mock_admin_user():
"""A mock admin auth user object."""
user = MagicMock()
user.id = "admin-user-id"
user.email = "admin@example.com"
return user
def _make_supabase_mock():
"""Build a chainable Supabase client mock."""
supabase = MagicMock()
# Default table chain returns empty data
table_mock = MagicMock()
table_mock.select.return_value = table_mock
table_mock.insert.return_value = table_mock
table_mock.update.return_value = table_mock
table_mock.delete.return_value = table_mock
table_mock.upsert.return_value = table_mock
table_mock.eq.return_value = table_mock
table_mock.in_.return_value = table_mock
table_mock.limit.return_value = table_mock
table_mock.order.return_value = table_mock
table_mock.range.return_value = table_mock
table_mock.gte.return_value = table_mock
table_mock.lt.return_value = table_mock
table_mock.execute.return_value = MagicMock(data=[], count=0)
supabase.table.return_value = table_mock
supabase.auth = MagicMock()
return supabase