"""Public entry files must stay in sync with their reviewed source artifacts.""" import hashlib from pathlib import Path import unittest ROOT = Path(__file__).resolve().parents[1] class LayoutTests(unittest.TestCase): def same_bytes(self, public, source): self.assertEqual(hashlib.sha256((ROOT / public).read_bytes()).digest(), hashlib.sha256((ROOT / source).read_bytes()).digest(), public) def test_only_selected_imu_design_is_present(self): directories = {p.name for p in (ROOT / '3Dmodel').iterdir() if p.is_dir()} self.assertEqual(directories, {'print', 'v4_taller_rounded_imu'}) def test_selected_imu_parts_assembly_and_images_match(self): folder = '3Dmodel/v4_taller_rounded_imu/output' names = {'large_plate', 'sg90_mount', 'roll_frame', 'pitch_arm', 'imu_holder_TRIAL'} self.assertEqual({p.stem for p in (ROOT / '3Dmodel/print').glob('*.stl')}, names) for name in names: self.same_bytes(f'3Dmodel/print/{name}.stl', f'{folder}/print/{name}.stl') self.same_bytes('3Dmodel/assembly.step', f'{folder}/large_plate_imu_assembly.step') self.same_bytes('3Dmodel/assembly.png', f'{folder}/cad_assembly.png') self.same_bytes('3Dmodel/imu_placement.png', f'{folder}/imu_placement.png') def test_public_policy_matches_frozen_bc43(self): for name in ('actor.npz', 'policy.py', 'infer.py', 'examples/first_observation.json'): self.same_bytes('RL/' + name, 'RL/reproduction/v3/' + name) if __name__ == '__main__': unittest.main()