feat(tplus): 新增 T+ 只读同步服务与同步管理
This commit is contained in:
1 parent
78bef43c06
commit
4fe5916c2c
43 files changed
+3309
-388
No files matched your search
@@ -324,3 +324,36 @@ def normal(make_user, auth_headers) -> dict:
|
||||
user = make_user([ROLE_USER])
|
||||
user["headers"] = auth_headers(user)
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tplus_tasks(monkeypatch):
|
||||
"""隔离测试任务,仅清理此夹具创建的批次和异常。"""
|
||||
from app.core.config import Settings
|
||||
from app.models import TPlusSyncBatch, TPlusSyncError
|
||||
|
||||
settings = Settings(
|
||||
_env_file=None,
|
||||
app_secret_key="x" * 32,
|
||||
t_plus_enabled=True,
|
||||
t_plus_database="unit_tplus",
|
||||
t_plus_user="reader",
|
||||
t_plus_odbc_driver="unit",
|
||||
)
|
||||
monkeypatch.setattr("app.services.tplus.task_service.get_settings", lambda: settings)
|
||||
keys = []
|
||||
|
||||
def payload():
|
||||
key = str(uuid.uuid4())
|
||||
keys.append(key)
|
||||
return {"task_type": "READ", "entity_types": ["personnel"], "request_key": key}
|
||||
|
||||
yield payload
|
||||
with get_session_factory()() as db:
|
||||
numbers = list(
|
||||
db.scalars(select(TPlusSyncBatch.batch_no).where(TPlusSyncBatch.request_key.in_(keys)))
|
||||
)
|
||||
if numbers:
|
||||
db.execute(delete(TPlusSyncError).where(TPlusSyncError.batch_no.in_(numbers)))
|
||||
db.execute(delete(TPlusSyncBatch).where(TPlusSyncBatch.batch_no.in_(numbers)))
|
||||
db.commit()
|
||||
Reference in new issue
Block a user