🎯 New Structure: - landing/ (root) - Only Makefile, .gitignore, .woodpecker.yml - helm/ - Kubernetes deployment (with argocd inside chart) - docker/ - Docker build configs - peikarband/ - All source code (src, tests, assets, config, tools, docs) ✅ Changes: - Moved Docker files: build/docker/ → docker/ - Moved Helm charts: deploy/helm/ → helm/ - Moved ArgoCD: deploy/argocd/ → helm/peikarband/argocd/ - Moved all source code to peikarband/ - Removed duplicate files (7 files) - Removed old empty directories 🐳 Docker Fixes: - Added npm retry configuration (fetch-retry-mintimeout, etc.) - Added 3-attempt retry mechanism for reflex export - Fixed ECONNREFUSED errors - Updated paths for new structure 📦 Config Updates: - Makefile: Updated all paths (docker/, helm/, peikarband/) - .woodpecker.yml: Updated dockerfile and context paths - .gitignore: Updated data/ path 🧪 Tests: - ✓ Helm lint passes - ✓ All paths validated - ✓ Structure verified 📊 Result: - Before: 20+ files in root, scattered structure - After: 3 files + 3 directories, clean and organized - Production-ready ✨
83 lines
1.7 KiB
Python
83 lines
1.7 KiB
Python
"""Pytest configuration and fixtures.
|
|
|
|
This module contains shared fixtures for all tests.
|
|
"""
|
|
|
|
import pytest
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, Session
|
|
from typing import Generator
|
|
|
|
from src.config.database import Base
|
|
from src.infrastructure.cache.redis_client import get_redis
|
|
|
|
|
|
# Test Database
|
|
TEST_DATABASE_URL = "sqlite:///./test.db"
|
|
|
|
engine = create_engine(
|
|
TEST_DATABASE_URL,
|
|
connect_args={"check_same_thread": False}
|
|
)
|
|
TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def db_session() -> Generator[Session, None, None]:
|
|
"""Create a fresh database session for each test.
|
|
|
|
Yields:
|
|
Session: Database session
|
|
"""
|
|
Base.metadata.create_all(bind=engine)
|
|
session = TestingSessionLocal()
|
|
try:
|
|
yield session
|
|
finally:
|
|
session.close()
|
|
Base.metadata.drop_all(bind=engine)
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def redis_client():
|
|
"""Get Redis client for testing.
|
|
|
|
Returns:
|
|
Redis client instance
|
|
"""
|
|
client = get_redis()
|
|
yield client
|
|
# Cleanup
|
|
client.flushdb()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_user_data() -> dict:
|
|
"""Sample user data for testing.
|
|
|
|
Returns:
|
|
dict: User data
|
|
"""
|
|
return {
|
|
"email": "test@example.com",
|
|
"password": "SecurePassword123!",
|
|
"full_name": "Test User",
|
|
"phone": "+989123456789",
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_service_data() -> dict:
|
|
"""Sample service data for testing.
|
|
|
|
Returns:
|
|
dict: Service data
|
|
"""
|
|
return {
|
|
"name": "Test VPS",
|
|
"type": "vps",
|
|
"plan_id": 1,
|
|
"status": "active",
|
|
}
|
|
|