RoboHome / code /robohome /src /engine /tests /test_fusion_geometry_runtime.py
RoboParty Release
Unify robohome source, assets and scenes delivery
3f15e9f
Raw History Blame Contribute Delete
1.32 kB
from pathlib import Path
from types import SimpleNamespace
import tempfile
import unittest
from unittest.mock import patch
import numpy as np
from engine import geometry_validation as geometry
class GeometryRuntimeTests(unittest.TestCase):
def test_collapsed_or_open_mesh_never_reaches_native_constructor(self):
def forbidden(*args, **kwargs):
raise AssertionError('Unsafe topology reached native geometry')
backend = SimpleNamespace(Mesh64=forbidden)
for triangles in ([[0, 0, 1]], [[0, 1, 2]]):
with self.subTest(triangles=triangles):
_, _, solid = geometry._mesh(dict(name='bad', vertices=[
[0, 0, 0], [1, 0, 0], [0, 1, 0]], triangles=triangles), backend, np)
self.assertIsNone(solid)
def test_native_worker_crash_cannot_be_accepted(self):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
with patch('engine.process_control.execute_command',
return_value=dict(exit_code=-11, timed_out=False, cleanup_passed=True)):
with self.assertRaisesRegex(ValueError, 'worker failed'):
geometry._audit_in_worker(root/'manifest.json', root/'mesh.gz', {}, root, 10)
if __name__ == '__main__':
unittest.main()