Some checks failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
- Implemented Clean Architecture with Domain, Application, Infrastructure, Presentation layers - Added comprehensive project structure following SOLID principles - Created Kubernetes deployment with Helm charts (HPA, PDB, NetworkPolicy) - Configured ArgoCD for automated deployment (production + staging) - Implemented CI/CD pipeline with GitHub Actions - Added comprehensive documentation (handbook, architecture, coding standards) - Configured PostgreSQL, Redis, Celery for backend services - Created modern landing page with Persian fonts (Vazirmatn) - Added Docker multi-stage build for production - Configured development tools (pytest, black, flake8, mypy, isort) - Added pre-commit hooks for code quality - Implemented Makefile for common operations
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",
|
|
}
|
|
|