REFACTOR - MAdrid Open data file
This commit is contained in:
@@ -16,67 +16,3 @@ from app.core.database import Base, get_db
|
||||
from app.models.sales import SalesData
|
||||
from app.models.weather import WeatherData, WeatherForecast
|
||||
from app.models.traffic import TrafficData
|
||||
|
||||
# Test database URL
|
||||
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
|
||||
|
||||
# Create test engine
|
||||
test_engine = create_async_engine(
|
||||
TEST_DATABASE_URL,
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
)
|
||||
|
||||
TestingSessionLocal = async_sessionmaker(
|
||||
test_engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False
|
||||
)
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def db():
|
||||
"""Create test database session"""
|
||||
async with test_engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
async with TestingSessionLocal() as session:
|
||||
yield session
|
||||
|
||||
async with test_engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.drop_all)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
"""Create test client"""
|
||||
async def override_get_db():
|
||||
async with TestingSessionLocal() as session:
|
||||
yield session
|
||||
|
||||
app.dependency_overrides[get_db] = override_get_db
|
||||
|
||||
with TestClient(app) as test_client:
|
||||
yield test_client
|
||||
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
@pytest.fixture
|
||||
def test_tenant_id():
|
||||
"""Test tenant ID"""
|
||||
return uuid.uuid4()
|
||||
|
||||
@pytest.fixture
|
||||
def test_sales_data():
|
||||
"""Sample sales data for testing"""
|
||||
return {
|
||||
"date": datetime.now(),
|
||||
"product_name": "Pan Integral",
|
||||
"quantity_sold": 25,
|
||||
"revenue": 37.50,
|
||||
"location_id": "madrid_centro",
|
||||
"source": "test"
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def mock_auth_token():
|
||||
"""Mock authentication token"""
|
||||
return "Bearer test-token-123"
|
||||
Reference in New Issue
Block a user