fix(api): Phase 16 R4 測試修復 - ParsedOperation 向後兼容

問題:
- test_action_parsing.py 導入路徑未更新 (舊: approvals.py)
- ParsedOperation dataclass 不支援 tuple 解包

修復:
- 更新測試導入至 src.services.operation_parser
- 新增 ParsedOperation.__iter__() 支援 tuple 解包

測試: 24/24 passed (100%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-25 23:00:03 +08:00
parent 4b3d98cd0b
commit 0afaea63f8
3 changed files with 39 additions and 4 deletions

View File

@@ -29,12 +29,20 @@ class ParsedOperation:
operation_type: K8s 操作類型 (RESTART_DEPLOYMENT, DELETE_POD, etc.)
resource_name: 目標資源名稱
namespace: K8s Namespace (預設 "default")
Note:
支援 tuple 解包以向後兼容:
op, resource, ns = parse_operation_from_action(action)
"""
operation_type: OperationType | None
resource_name: str | None
namespace: str
def __iter__(self):
"""支援 tuple 解包: op, resource, ns = parsed"""
return iter((self.operation_type, self.resource_name, self.namespace))
def parse_operation_from_action(action: str) -> ParsedOperation:
"""