Replace TownSquare with HomeCamp art and land humanoid bots, LittleBear, and LmGirl review assets.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Guard the shared scene CLI's no-service planning and reuse paths."""
|
||||
import contextlib
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import scene_component_pipeline as pipeline
|
||||
|
||||
|
||||
class SceneComponentPlanningTests(unittest.TestCase):
|
||||
def invoke(self, root, data, *extra):
|
||||
manifest = root / 'scene.json'
|
||||
manifest.write_text(json.dumps(data), encoding='utf-8')
|
||||
output = io.StringIO()
|
||||
with mock.patch.object(pipeline, 'ROOT', root), contextlib.redirect_stdout(output), \
|
||||
mock.patch.object(pipeline.subprocess, 'run', side_effect=AssertionError('Planner called a service')):
|
||||
code = pipeline.main(argv=['--manifest', str(manifest), '--part', 'tree', *extra])
|
||||
return code, json.loads(output.getvalue())
|
||||
|
||||
def test_dry_run_works_without_highpoly_or_backend_and_does_not_create_outputs(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = Path(folder)
|
||||
code, plan = self.invoke(root, {'sceneId': 'NewScene', 'components': [
|
||||
{'type': 'tree', 'designImage': 'design/tree.png', 'targetTriangles': 700}]}, '--dry-run')
|
||||
self.assertEqual(code, 0)
|
||||
self.assertEqual(plan['highpolyCommand'][-3], '50k')
|
||||
self.assertEqual(plan['steps'][1:3], ['studio_lowpoly', 'studio_uv'])
|
||||
self.assertFalse((root / 'Tools').exists())
|
||||
|
||||
def test_reused_prefab_needs_no_design_image_or_source_model(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
code, result = self.invoke(Path(folder), {'sceneId': 'NewScene', 'components': [
|
||||
{'type': 'tree', 'generationStatus': 'reused', 'prefab': 'Assets/Common/tree.prefab'}]})
|
||||
self.assertEqual(code, 0)
|
||||
self.assertEqual(result, {'part': 'tree', 'status': 'reused', 'prefab': 'Assets/Common/tree.prefab'})
|
||||
|
||||
def test_output_override_cannot_write_outside_production_directory(self):
|
||||
with tempfile.TemporaryDirectory() as folder, contextlib.redirect_stderr(io.StringIO()):
|
||||
root = Path(folder)
|
||||
with self.assertRaises(SystemExit) as error:
|
||||
self.invoke(root, {'sceneId': 'NewScene', 'components': [
|
||||
{'id': 'tree', 'designImage': 'tree.png', 'targetTriangles': 700}]},
|
||||
'--output-dir', str(root / 'Assets'), '--dry-run')
|
||||
self.assertEqual(error.exception.code, 2)
|
||||
self.assertFalse((root / 'Assets').exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user