P08-03: 配置の通常操作受入
This commit is contained in:
@@ -98,6 +98,83 @@ class EvidenceTests(unittest.TestCase):
|
||||
def test_positive_whole_checker(self):
|
||||
self.assertEqual([], C.check(self.root, self.out))
|
||||
|
||||
def action_row(self, label):
|
||||
rows = C.load(self.out/'pair/writer-actions.json')['actions']
|
||||
return copy.deepcopy(next(row for row in rows if row['id'] == label))
|
||||
|
||||
def action_check(self, row, message=None, mutate_state=None):
|
||||
def typed(name):
|
||||
node = C.load(self.out/('pair/'+name+'.json'))
|
||||
if mutate_state and name == row['after']:
|
||||
mutate_state(node)
|
||||
return node
|
||||
if message:
|
||||
with self.assertRaisesRegex(ValueError, message):
|
||||
C.action_gate(row, typed, self.root)
|
||||
else:
|
||||
C.action_gate(row, typed, self.root)
|
||||
|
||||
def test_agreeing_preview_refusal(self):
|
||||
row = self.action_row('missing_connection')
|
||||
self.assertEqual(row['status'], row['report']['reasons'][0]['message'])
|
||||
self.action_check(row)
|
||||
|
||||
def test_preview_command_disagreement(self):
|
||||
row = self.action_row('missing_connection')
|
||||
row['report']['can_build'] = True
|
||||
row['results'] = [{'code':'VALIDATION_FAILED', 'details':{'reason':'STAIR_LANDING_MISSING'}, 'message':row['status']}]
|
||||
self.action_check(row, 'preview/command disagreement')
|
||||
|
||||
def test_preview_runtime_reason_difference(self):
|
||||
row = self.action_row('missing_connection')
|
||||
row['report']['error_codes'] = ['OVERLAP']
|
||||
row['results'] = [{'code':'VALIDATION_FAILED', 'details':{'reason':'STAIR_LANDING_MISSING'}, 'message':row['status']}]
|
||||
self.action_check(row, 'preview reason differs from Runtime reason')
|
||||
|
||||
def test_preview_partial_state_change(self):
|
||||
self.action_check(self.action_row('missing_connection'), 'cancel/preview partially applied',
|
||||
lambda node: C.typed_member(node, 'game_state', 'resources', 'materials').update(text='999'))
|
||||
|
||||
def test_readable_demolition_success(self):
|
||||
row = self.action_row('demolition')
|
||||
self.assertEqual('撤去しました(返金: 資材 2)', row['status'])
|
||||
self.action_check(row)
|
||||
|
||||
def test_demolition_missing_refund_amount(self):
|
||||
row = self.action_row('demolition'); row['status'] = '撤去しました(返金: 資材)'
|
||||
self.action_check(row, 'demolition refund display mismatch')
|
||||
|
||||
def test_demolition_wrong_refund_amount(self):
|
||||
row = self.action_row('demolition'); row['status'] = '撤去しました(返金: 資材 3)'
|
||||
self.action_check(row, 'demolition refund display mismatch')
|
||||
|
||||
def test_demolition_raw_enum_status(self):
|
||||
row = self.action_row('demolition'); row['status'] = 'OK | |'
|
||||
self.action_check(row, 'raw demolition token in status')
|
||||
|
||||
def test_readable_demolition_refusal(self):
|
||||
row = self.action_row('refused_demolition')
|
||||
self.assertEqual('STAIR_LANDING_IN_USE', row['results'][0]['details']['reason'])
|
||||
self.assertEqual('撤去できません: '+row['results'][0]['message'], row['status'])
|
||||
self.action_check(row)
|
||||
|
||||
def test_demolition_raw_reason_status(self):
|
||||
row = self.action_row('refused_demolition'); row['status'] += ' STAIR_LANDING_IN_USE'
|
||||
self.action_check(row, 'raw demolition token in status')
|
||||
|
||||
def test_demolition_altered_refusal_message(self):
|
||||
for status in ('撤去できません', '撤去できません: altered'):
|
||||
row = self.action_row('refused_demolition'); row['status'] = status
|
||||
self.action_check(row, 'demolition refusal message mismatch')
|
||||
|
||||
def test_demolition_raw_reason_mismatch(self):
|
||||
row = self.action_row('refused_demolition')
|
||||
row['results'][0]['details']['reason'] = 'OTHER'
|
||||
def mutate(node):
|
||||
items = C.typed_member(node, 'systems', 'runtime', 'command_queue', 'processed')['items']
|
||||
items[-1] = F.typed(row['results'][0])
|
||||
self.action_check(row, 'reason mismatch', mutate)
|
||||
|
||||
def test_verify_only_cli_uses_build_output_directory(self):
|
||||
output = io.StringIO()
|
||||
with patch.dict(os.environ, {'BUILD_OUTPUT_DIR':str(self.out.parent)}), contextlib.redirect_stdout(output):
|
||||
|
||||
Reference in New Issue
Block a user