Files
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

36 lines
2.2 KiB
Python

import json,struct,sys,tempfile,unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
from taxi_profile import compare,header,path_header
class TaxiProfileTest(unittest.TestCase):
def test_definition_intersection_and_determinism(self):
with tempfile.TemporaryDirectory()as d:
p=Path(d);strings=b'\0Test Stop\0';rows=[]
for ident in range(1,7):rows.append([ident,1,*[struct.unpack('<I',struct.pack('<f',v))[0]for v in (10.,20.,30.)],1,*([0]*10)])
data=struct.pack('<4s4I',b'WDBC',6,16,64,len(strings))+b''.join(struct.pack('<16I',*r)for r in rows)+strings
(p/'nodes.dbc').write_bytes(data)
target=[dict(ID=i,Name_lang='Test Stop',ContinentID=1,CharacterBitNumber=i,Pos=[10.,20.,30.])for i in range(1,6)]
target[1]['Name_lang']='Unrelated stop';target[2]['ContinentID']=0;target[3]['CharacterBitNumber']=40;target[4]['Pos'][0]=11
(p/'native.json').write_text(json.dumps(target));r=compare(p/'nodes.dbc',p/'native.json')
self.assertEqual(r['supported'],[1]);self.assertEqual(len(r['excluded']),5)
self.assertEqual(r,compare(p/'nodes.dbc',p/'native.json'));self.assertIn('SupportedMask={1,0',header(r))
def test_route_graph_null_rows_and_ambiguity(self):
with tempfile.TemporaryDirectory()as d:
p=Path(d)/'paths.dbc'
def write(rows):p.write_bytes(struct.pack('<4s4I',b'WDBC',len(rows),4,16,1)+b''.join(struct.pack('<4I',*r)for r in rows)+b'\0')
write([(1,23,40,10),(296,0,0,0)])
self.assertIn('Paths[]={{23,40,10}}',path_header(p))
self.assertEqual(path_header(p),path_header(p))
write([(1,23,40,10),(2,40,82,20),(296,0,0,0)])
self.assertIn('Paths[]={{23,40,10}}',path_header(p,{23,40}))
self.assertIn('Paths[]={{23,40,10},{40,82,20}}',path_header(p,{23,40,82}))
for supported in (set(),{0},{257},{True}):
with self.assertRaises(ValueError):path_header(p,supported)
for rows in ([(1,0,40,10)],[(1,23,40,10000001)],[(1,23,40,10),(2,23,40,20)]):
write(rows)
with self.assertRaises(ValueError):path_header(p)
def test_bad_mask_identity_rejected(self):
for ids in ([],[1,1],[0],[257],[True]):
with self.assertRaises(ValueError):header({'supported':ids})
if __name__=='__main__':unittest.main()