修复:明确旧删除接口固定拒绝

This commit is contained in:
焦龙言
2026-09-22 19:00:38 +08:00
parent 46eff756de
commit 43fe17cc70
8 changed files with 42 additions and 12 deletions
@@ -965,6 +965,21 @@ class TestMasterControllers(unittest.TestCase):
self.assertIn(f'{prefix}/{{{resource}_id}}', schema['paths'])
self.assertIn('get', schema['paths'][f'{prefix}/{{{resource}_id}}'])
def test_legacy_delete_openapi_declares_fixed_rejection(self) -> None:
app = FastAPI()
for router in self.ROUTERS.values():
app.include_router(router)
schema = app.openapi()
expected_summary = '兼容旧接口,固定拒绝,请使用测试数据批次清理'
expected_description = '兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理'
for resource in self.ROUTERS:
with self.subTest(resource=resource):
operation = schema['paths'][f'/master/{resource}/{{{resource}_ids}}']['delete']
self.assertEqual(expected_summary, operation['summary'])
self.assertEqual(expected_description, operation['description'])
self.assertNotIn('用于删除', operation['description'])
def test_all_twenty_five_permission_dependencies_are_exact(self) -> None:
expected_permissions = {
(f'/master/{resource}/list', 'GET'): f'master:{resource}:list' for resource in self.ROUTERS
@@ -1263,6 +1263,21 @@ class TestPalletAndAssignmentControllers(unittest.IsolatedAsyncioTestCase):
schema['paths']['/master/pallet/{pallet_id}/qrcode']['get']['responses']['200']['content'],
)
def test_legacy_delete_openapi_declares_fixed_rejection(self) -> None:
app = FastAPI()
for router in self._routers():
app.include_router(router)
operation = app.openapi()['paths']['/master/pallet/{pallet_ids}']['delete']
self.assertEqual('兼容旧接口,固定拒绝,请使用测试数据批次清理', operation['summary'])
self.assertEqual(
'兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
operation['description'],
)
self.assertNotIn('用于删除', operation['description'])
self.assertNotIn('尚未入库', operation['description'])
self.assertNotIn('没有流转事件', operation['description'])
def test_route_response_models_are_exact(self) -> None:
routes = self._routes()
self.assertEqual(