P08-03: 配置の通常操作受入
This commit is contained in:
@@ -13,6 +13,8 @@ import shutil
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import gzip
|
||||
import hashlib
|
||||
|
||||
sys.dont_write_bytecode = True
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -331,6 +333,25 @@ class EvidenceTests(unittest.TestCase):
|
||||
self.edit('os-pair/unsupported-1/ack.json', lambda d: d.update(request_sha256='0'*64))
|
||||
self.reject('OS ack request mismatch')
|
||||
|
||||
def test_os_canvas_mapping_drift(self):
|
||||
self.edit('os-pair/unsupported-1/request.json', lambda d: d.update(viewport_to_screen=[1,0,0,1,32,0]))
|
||||
# Repin acknowledgement too: test semantics, rather than checksum rejection.
|
||||
self.edit('os-pair/unsupported-1/ack.json', lambda d: d.update(request_sha256=C.sha(self.out/'os-pair/unsupported-1/request.json')))
|
||||
self.reject('OS canvas mapping drift')
|
||||
|
||||
def test_os_guide_interception(self):
|
||||
self.edit('os-pair/unsupported-1/request.json', lambda d: d.update(guide_visible=True,guide_rect=[0,0,10000,10000]))
|
||||
self.edit('os-pair/unsupported-1/ack.json', lambda d: d.update(request_sha256=C.sha(self.out/'os-pair/unsupported-1/request.json')))
|
||||
self.reject('OS guide interception')
|
||||
|
||||
def test_whole_checker_missing_stair_projection(self):
|
||||
self.edit('pair/writer-lower_stair-completed.json', lambda d: C.typed_member(d,'systems','runtime','facility_infrastructure','projections')['items'].pop())
|
||||
self.reject('missing/extra infrastructure projection')
|
||||
|
||||
def test_whole_checker_wrong_stair_connector(self):
|
||||
self.edit('pair/writer-lower_stair-completed.json', lambda d: C.typed_member(C.typed_member(d,'systems','runtime','path','connectors')['items'][0],'cost').update(text='999'))
|
||||
self.reject('wrong infrastructure connector topology')
|
||||
|
||||
def test_refusal_cannot_be_relabelled(self):
|
||||
self.edit('pair/writer-actions.json', lambda d: d['actions'][4].update(expected='OTHER_REASON'))
|
||||
self.reject('required refusal reason changed')
|
||||
@@ -411,5 +432,70 @@ class EvidenceTests(unittest.TestCase):
|
||||
def test_mock_native_timeout_restores_project_and_cleans_owned_child(self):
|
||||
self.collector_mock(fail_wait=True)
|
||||
|
||||
class RealR05InfrastructureTests(unittest.TestCase):
|
||||
"""Actual native snapshot, never a fabricated acceptance specimen."""
|
||||
def setUp(self):
|
||||
folder = ROOT/'tests/fixtures/p08-03'
|
||||
provenance = json.loads((folder/'r05-reader-checkpoint-provenance.json').read_bytes())
|
||||
raw = gzip.decompress((folder/'r05-reader-checkpoint.json.gz').read_bytes())
|
||||
self.assertEqual(provenance['raw_sha256'],hashlib.sha256(raw).hexdigest())
|
||||
self.assertEqual(provenance['raw_bytes'],len(raw))
|
||||
self.node = json.loads(raw)
|
||||
self.model = C.decode(self.node)
|
||||
|
||||
def test_real_reader_checkpoint(self):
|
||||
self.assertEqual(self.model,C.state(self.node))
|
||||
|
||||
def reject(self, mutate, message):
|
||||
runtime = self.model['systems']['runtime']; mutate(runtime)
|
||||
with self.assertRaisesRegex(ValueError,message): C.state(F.typed(self.model))
|
||||
|
||||
def test_missing_projection(self):
|
||||
self.reject(lambda r:r['facility_infrastructure']['projections'].pop(),'missing/extra infrastructure projection')
|
||||
|
||||
def test_extra_projection(self):
|
||||
def mutate(r):
|
||||
p=copy.deepcopy(r['facility_infrastructure']['projections'][0]); p['instance_id']='ghost'
|
||||
r['facility_infrastructure']['projections'].append(p)
|
||||
self.reject(mutate,'missing/extra infrastructure projection')
|
||||
|
||||
def test_wrong_projected_cells(self):
|
||||
self.reject(lambda r:r['facility_infrastructure']['projections'][0].update(cells=[[9,9,0]]),'wrong infrastructure projection')
|
||||
|
||||
def test_missing_route(self):
|
||||
self.reject(lambda r:r['spatial_subslots']['entities'].pop(),'wrong infrastructure ROUTE topology')
|
||||
|
||||
def test_extra_route(self):
|
||||
self.reject(lambda r:r['spatial_subslots']['entities'].append({'entity_id':'infra.route:ghost','category':'ROUTE','cells':[[8,4,0]]}),'extra infrastructure ROUTE topology')
|
||||
|
||||
def test_wrong_route(self):
|
||||
self.reject(lambda r:r['spatial_subslots']['entities'][0].update(category='UTILITY'),'wrong infrastructure ROUTE topology')
|
||||
|
||||
def test_missing_connector(self):
|
||||
self.reject(lambda r:r['path']['connectors'].pop(0),'wrong infrastructure connector topology')
|
||||
|
||||
def test_extra_connector(self):
|
||||
def mutate(r):
|
||||
c=copy.deepcopy(r['path']['connectors'][0]); c['id']='infra.connector:ghost'; r['path']['connectors'].append(c)
|
||||
self.reject(mutate,'extra infrastructure connector topology')
|
||||
|
||||
def test_wrong_connector(self):
|
||||
self.reject(lambda r:r['path']['connectors'][0].update(to=[8,0,0]),'wrong infrastructure connector topology')
|
||||
|
||||
def test_wrong_projected_walkable(self):
|
||||
self.reject(lambda r:r['route_projection']['projected_walkable_cells'].pop(),'wrong projected walkable topology')
|
||||
|
||||
def test_wrong_path_cells(self):
|
||||
self.reject(lambda r:r['path']['cell_traffic'].pop(),'wrong projected walkable topology')
|
||||
|
||||
def test_ordinary_facility_loss(self):
|
||||
self.reject(lambda r:r['facilities']['instances'].clear(),'partial demolition/completion')
|
||||
|
||||
def test_proxy_occupancy_loss(self):
|
||||
self.reject(lambda r:r['world']['occupancies'].pop(),'orphan/lost occupancy')
|
||||
|
||||
def test_proxy_operational_duplication(self):
|
||||
self.reject(lambda r:r['facilities']['instances'].append(copy.deepcopy(r['construction']['facilities'][0])),'partial demolition/completion')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user