P08-03: 配置の通常操作受入
This commit is contained in:
@@ -568,10 +568,13 @@ def action_gate(row, typed, root=HERE.parent):
|
||||
require(row['report']['error_codes'][0] == code and row['status'] == message, 'reason mismatch')
|
||||
require(not row['report']['can_build'] and not results, 'preview rejection bypassed')
|
||||
preserve(before, after, results)
|
||||
elif label == 'missing_connection' and not results:
|
||||
elif label == 'missing_connection':
|
||||
require(not results, 'preview rejection bypassed')
|
||||
require(not row['report']['can_build'], 'preview/command disagreement')
|
||||
require('STAIR_LANDING_MISSING' in row['report']['error_codes'], 'preview reason differs from Runtime reason')
|
||||
require(row['report']['reasons'] and row['status'] == row['report']['reasons'][0]['message'], 'connection reason mismatch')
|
||||
reason = next((entry for entry in row['report'].get('reasons', []) if isinstance(entry, dict) and entry.get('code') == 'STAIR_LANDING_MISSING'), {})
|
||||
message = reason.get('message')
|
||||
require(isinstance(message, str) and bool(message) and row['status'] == '配置不可: '+message and 'STAIR_LANDING_MISSING' not in row['status'], 'connection reason mismatch')
|
||||
preserve(before, after, [])
|
||||
elif kind == 'cancel':
|
||||
require(not results and row['status'] == '撤去を取り消しました。', 'cancel submitted command')
|
||||
@@ -622,9 +625,6 @@ def action_gate(row, typed, root=HERE.parent):
|
||||
require(set(resources_a) == set(resources_b) and all(resources_b[k] == v - cost.get(k, 0) for k, v in resources_a.items()), 'build cost mismatch')
|
||||
if label == 'supported_connected':
|
||||
require(row['report']['connection']['status'] == 'CONNECTED', 'positive connection absent')
|
||||
if label == 'missing_connection':
|
||||
require(row['status'] == '操作に失敗しました: '+result['message'], 'connection reason mismatch')
|
||||
require(not row['report']['can_build'], 'preview/command disagreement')
|
||||
|
||||
def check(project_root, evidence_dir):
|
||||
root, evidence = Path(project_root).resolve(), Path(evidence_dir).resolve()
|
||||
|
||||
@@ -116,9 +116,28 @@ class EvidenceTests(unittest.TestCase):
|
||||
|
||||
def test_agreeing_preview_refusal(self):
|
||||
row = self.action_row('missing_connection')
|
||||
self.assertEqual(row['status'], row['report']['reasons'][0]['message'])
|
||||
self.assertEqual(row['status'], '配置不可: '+row['report']['reasons'][0]['message'])
|
||||
self.action_check(row)
|
||||
|
||||
def test_connection_status_corruptions(self):
|
||||
for status in ('先に階段の一つ下の階に通路を作ってください。', '配置不可: STAIR_LANDING_MISSING', '配置不可: wrong message'):
|
||||
with self.subTest(status=status):
|
||||
row = self.action_row('missing_connection')
|
||||
row['status'] = status
|
||||
self.action_check(row, 'connection reason mismatch')
|
||||
|
||||
def test_connection_reason_missing_or_empty(self):
|
||||
for reasons in ([], [{'code':'OTHER', 'message':'other'}], [{'code':'STAIR_LANDING_MISSING', 'message':''}]):
|
||||
with self.subTest(reasons=reasons):
|
||||
row = self.action_row('missing_connection')
|
||||
row['report']['reasons'] = reasons
|
||||
self.action_check(row, 'connection reason mismatch')
|
||||
|
||||
def test_connection_preview_rejection_bypassed(self):
|
||||
row = self.action_row('missing_connection')
|
||||
row['results'] = [{'code':'VALIDATION_FAILED', 'details':{'reason':'STAIR_LANDING_MISSING'}, 'message':row['status']}]
|
||||
self.action_check(row, 'preview rejection bypassed')
|
||||
|
||||
def test_preview_command_disagreement(self):
|
||||
row = self.action_row('missing_connection')
|
||||
row['report']['can_build'] = True
|
||||
|
||||
Reference in New Issue
Block a user