import json import unittest from prepare_user_scan_pair import graph class UserScanPairTest(unittest.TestCase): def test_both_variants_pause_acquisition_before_creating_project(self): for export in (False,True): with self.subTest(export=export): g=graph(export);actions=[n['properties']['action'] for n in g['nodes']] self.assertLess(actions.index('SCANNER_STOP'),actions.index('SCANNER_CREATE_PROJECT')) self.assertLess(actions.index('SCANNER_CREATE_PROJECT'),actions.index('SCANNER_START')) self.assertNotIn('SCANNER_SNAPSHOT',actions) self.assertEqual(len(g['edges']),len(g['nodes'])-1) for a,b,edge in zip(g['nodes'],g['nodes'][1:],g['edges']): self.assertEqual((edge['sourceNodeId'],edge['targetNodeId']),(a['id'],b['id'])) def test_preview_variant_stops_after_capture_and_has_no_model_processing(self): actions=[n['properties']['action'] for n in graph(False)['nodes']] self.assertEqual(actions[-2:],['SCANNER_STOP','END']) self.assertNotIn('SCANNER_MESH',actions);self.assertNotIn('SCANNER_EXPORT',actions) def test_export_only_after_stop_mesh_and_confirmation(self): nodes=graph(True)['nodes'];actions=[n['properties']['action'] for n in nodes] self.assertEqual(actions[-5:],['SCANNER_STOP','SCANNER_MESH','SCANNER_MESH_CONFIRM','SCANNER_EXPORT','END']) export=next(n for n in nodes if n['properties']['action']=='SCANNER_EXPORT') params={p['name']:p['input'] for p in export['properties']['nodeParams']} self.assertEqual(json.loads(params['requestJson'])['formats'],['PLY','STL']);self.assertEqual(params['timeoutMs'],600000) if __name__=='__main__':unittest.main()