38 lines
774 B
Python
38 lines
774 B
Python
import pytest
|
|
from fastapi.testclient import TestClient
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import SessionLocal
|
|
from app.main import app
|
|
from app.models.finished_goods import FinishedGoodsLocation
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
return TestClient(app)
|
|
|
|
|
|
@pytest.fixture
|
|
def db():
|
|
session = SessionLocal()
|
|
yield session
|
|
session.close()
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def cleanup_test_data(db: Session):
|
|
yield
|
|
test_zongpai_nos = [
|
|
"26B999",
|
|
"26C999",
|
|
"26BW0999",
|
|
"26T999",
|
|
"26T998",
|
|
"26B998",
|
|
"26C998",
|
|
]
|
|
db.query(FinishedGoodsLocation).filter(
|
|
FinishedGoodsLocation.zongpai_no.in_(test_zongpai_nos)
|
|
).delete(synchronize_session=False)
|
|
db.commit()
|