unitytk 0.8.0__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unitytk-0.8.0 → unitytk-0.9.0}/MANIFEST.in +1 -0
- {unitytk-0.8.0/unitytk.egg-info → unitytk-0.9.0}/PKG-INFO +4 -2
- {unitytk-0.8.0 → unitytk-0.9.0}/docs/README.md +2 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/pyproject.toml +15 -7
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_base_test.py +88 -3
- unitytk-0.9.0/tests/test_indicator_glow_twin.py +79 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_project_builder.py +161 -0
- unitytk-0.9.0/tests/test_sample_task.py +122 -0
- unitytk-0.9.0/tests/test_sheet_cells.py +508 -0
- unitytk-0.9.0/tests/test_sheet_check.py +529 -0
- unitytk-0.9.0/tests/test_sheet_converter.py +259 -0
- unitytk-0.9.0/tests/test_sheet_plan.py +1769 -0
- unitytk-0.9.0/tests/test_sheet_settings.py +364 -0
- unitytk-0.9.0/tests/test_sheet_spec.py +154 -0
- unitytk-0.9.0/tests/test_sheet_sync.py +282 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_temp_projects.py +10 -9
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_unity_cli.py +92 -12
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_unity_compile.py +54 -1
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_unity_host.py +7 -4
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/__init__.py +1 -1
- unitytk-0.9.0/unitytk/operations.json +322 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/operations.py +24 -1
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/project_builder.py +145 -8
- unitytk-0.9.0/unitytk/sheets/AGENTS.md +21 -0
- unitytk-0.9.0/unitytk/sheets/CLAUDE.md +1 -0
- unitytk-0.9.0/unitytk/sheets/__init__.py +34 -0
- unitytk-0.9.0/unitytk/sheets/_cell_reading.py +316 -0
- unitytk-0.9.0/unitytk/sheets/_cell_writing.py +240 -0
- unitytk-0.9.0/unitytk/sheets/_plan_reading.py +607 -0
- unitytk-0.9.0/unitytk/sheets/_row_reading.py +559 -0
- unitytk-0.9.0/unitytk/sheets/clause_book.py +293 -0
- unitytk-0.9.0/unitytk/sheets/clause_spec.py +186 -0
- unitytk-0.9.0/unitytk/sheets/clauses/advance.json +12 -0
- unitytk-0.9.0/unitytk/sheets/clauses/answer.json +13 -0
- unitytk-0.9.0/unitytk/sheets/clauses/answer_else.json +17 -0
- unitytk-0.9.0/unitytk/sheets/clauses/buttons.json +13 -0
- unitytk-0.9.0/unitytk/sheets/clauses/check.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/checklist.json +12 -0
- unitytk-0.9.0/unitytk/sheets/clauses/checklist_hide.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/exit.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/fade_in.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/fade_out.json +12 -0
- unitytk-0.9.0/unitytk/sheets/clauses/goto.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/highlight.json +13 -0
- unitytk-0.9.0/unitytk/sheets/clauses/hold.json +8 -0
- unitytk-0.9.0/unitytk/sheets/clauses/indicate.json +13 -0
- unitytk-0.9.0/unitytk/sheets/clauses/marker_hide.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/marker_show.json +8 -0
- unitytk-0.9.0/unitytk/sheets/clauses/note.json +8 -0
- unitytk-0.9.0/unitytk/sheets/clauses/number_pad.json +12 -0
- unitytk-0.9.0/unitytk/sheets/clauses/pause.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/pip.json +9 -0
- unitytk-0.9.0/unitytk/sheets/clauses/pip_hide.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/placard.json +12 -0
- unitytk-0.9.0/unitytk/sheets/clauses/place.json +17 -0
- unitytk-0.9.0/unitytk/sheets/clauses/play.json +9 -0
- unitytk-0.9.0/unitytk/sheets/clauses/press_hold.json +15 -0
- unitytk-0.9.0/unitytk/sheets/clauses/quiz.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/return.json +13 -0
- unitytk-0.9.0/unitytk/sheets/clauses/select.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/set_state.json +8 -0
- unitytk-0.9.0/unitytk/sheets/clauses/show.json +15 -0
- unitytk-0.9.0/unitytk/sheets/clauses/take.json +11 -0
- unitytk-0.9.0/unitytk/sheets/clauses/teleport.json +17 -0
- unitytk-0.9.0/unitytk/sheets/clauses/turn_on.json +8 -0
- unitytk-0.9.0/unitytk/sheets/clauses/use.json +15 -0
- unitytk-0.9.0/unitytk/sheets/delivery_index.py +622 -0
- unitytk-0.9.0/unitytk/sheets/node_matcher.py +407 -0
- unitytk-0.9.0/unitytk/sheets/reading_spec.py +423 -0
- unitytk-0.9.0/unitytk/sheets/readings/default.json +402 -0
- unitytk-0.9.0/unitytk/sheets/readings/interactive.json +36 -0
- unitytk-0.9.0/unitytk/sheets/readings/linear.json +27 -0
- unitytk-0.9.0/unitytk/sheets/sheet_check.py +873 -0
- unitytk-0.9.0/unitytk/sheets/sheet_converter.py +405 -0
- unitytk-0.9.0/unitytk/sheets/sheet_plan.py +539 -0
- unitytk-0.9.0/unitytk/sheets/sheet_settings.py +272 -0
- unitytk-0.9.0/unitytk/sheets/sheet_sync.py +199 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/unity_cli.py +67 -9
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/unity_compile.py +67 -35
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/unity_project.py +44 -0
- {unitytk-0.8.0 → unitytk-0.9.0/unitytk.egg-info}/PKG-INFO +4 -2
- unitytk-0.9.0/unitytk.egg-info/SOURCES.txt +97 -0
- unitytk-0.9.0/unitytk.egg-info/requires.txt +1 -0
- unitytk-0.8.0/unitytk/operations.json +0 -158
- unitytk-0.8.0/unitytk.egg-info/SOURCES.txt +0 -34
- unitytk-0.8.0/unitytk.egg-info/requires.txt +0 -1
- {unitytk-0.8.0 → unitytk-0.9.0}/COPYING +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/COPYING.LESSER +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/setup.cfg +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_articulated_rig_runtime.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_editor_catalog.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_generated_files_hook.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_keyed_visibility.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_package.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_run_tests.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_shadow_plane_runtime_integration.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/tests/test_unity_kernel_live.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/editor_operations.json +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk/unity_host.py +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk.egg-info/dependency_links.txt +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk.egg-info/entry_points.txt +0 -0
- {unitytk-0.8.0 → unitytk-0.9.0}/unitytk.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unitytk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: The automation beside the unitytk Unity package: an owned editor for agents, the test and demo project, a compile check.
|
|
5
5
|
Author-email: Ryan Simpson <m3trik@outlook.com>
|
|
6
6
|
License: LGPL-3.0-or-later
|
|
@@ -14,7 +14,7 @@ Requires-Python: >=3.9
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: COPYING
|
|
16
16
|
License-File: COPYING.LESSER
|
|
17
|
-
Requires-Dist: pythontk>=0.
|
|
17
|
+
Requires-Dist: pythontk>=0.26.0
|
|
18
18
|
Dynamic: license-file
|
|
19
19
|
|
|
20
20
|
[](https://www.gnu.org/licenses/lgpl-3.0.en.html)
|
|
@@ -36,6 +36,8 @@ The Python side drives Unity from outside, with Unity's own tools: `UnityHost` (
|
|
|
36
36
|
|
|
37
37
|
## More
|
|
38
38
|
|
|
39
|
+
- [A scene from a build sheet: the manifest](manifest.md) — a sheet and its delivery staged into a project (`sheet.sync`, `unitytk.sheets`), the Manifest window that assesses and builds the scene from them, and how each half extends
|
|
40
|
+
- [The Tasks kit](tasks.md) — the first set of behaviors a sheet's rows read as: the phrases, what each builds, the building blocks, the sample task
|
|
39
41
|
- [The Unity package's README](../com.m3trik.unitytk/README.md) — the package's catalog, the FBX import contract, and installing it (one Package Manager line)
|
|
40
42
|
- [pythontk's `DELIVERABLE_FORMAT.md`](https://github.com/m3trik/pythontk/blob/main/pythontk/core_utils/engines/scene_export/DELIVERABLE_FORMAT.md) — the data a deliverable carries, which the package reads (the `data_export` carrier and every scene record's block)
|
|
41
43
|
- [`CHANGELOG.md`](../CHANGELOG.md) — notable changes
|
|
@@ -17,6 +17,8 @@ The Python side drives Unity from outside, with Unity's own tools: `UnityHost` (
|
|
|
17
17
|
|
|
18
18
|
## More
|
|
19
19
|
|
|
20
|
+
- [A scene from a build sheet: the manifest](manifest.md) — a sheet and its delivery staged into a project (`sheet.sync`, `unitytk.sheets`), the Manifest window that assesses and builds the scene from them, and how each half extends
|
|
21
|
+
- [The Tasks kit](tasks.md) — the first set of behaviors a sheet's rows read as: the phrases, what each builds, the building blocks, the sample task
|
|
20
22
|
- [The Unity package's README](../com.m3trik.unitytk/README.md) — the package's catalog, the FBX import contract, and installing it (one Package Manager line)
|
|
21
23
|
- [pythontk's `DELIVERABLE_FORMAT.md`](https://github.com/m3trik/pythontk/blob/main/pythontk/core_utils/engines/scene_export/DELIVERABLE_FORMAT.md) — the data a deliverable carries, which the package reads (the `data_export` carrier and every scene record's block)
|
|
22
24
|
- [`CHANGELOG.md`](../CHANGELOG.md) — notable changes
|
|
@@ -17,12 +17,14 @@ classifiers = [
|
|
|
17
17
|
]
|
|
18
18
|
# The floor is HAND-RATCHETED: unitytk is off-chain from m3trik/push.ps1, so no
|
|
19
19
|
# release cascade bumps it; m3trik's `check_api_surface.py unitytk --floors`
|
|
20
|
-
# holds it to every pythontk name the automation calls. 0.
|
|
21
|
-
#
|
|
22
|
-
# `
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
|
|
20
|
+
# holds it to every pythontk name the automation calls. 0.26.0: the sheet
|
|
21
|
+
# reader (`unitytk.sheets`) reads through the Shot Manifest parser's
|
|
22
|
+
# `Mapping.resolve(base=)`, `Mapping.unmapped_columns`, `BuilderStep.rows` and
|
|
23
|
+
# `lines`, the templates' `row_pass` and the `narrate` audio method, and
|
|
24
|
+
# `FbxFile.take_setup_jumps`, none of them in 0.25.1 (pythontk releases first).
|
|
25
|
+
# Unity's CLI is unitytk's own (`unitytk.UnityCli`, standard library only).
|
|
26
|
+
# The Unity package itself needs no Python at all.
|
|
27
|
+
dependencies = ["pythontk>=0.26.0"]
|
|
26
28
|
|
|
27
29
|
# Operations (``python -m pythontk ops``): unitytk's declarations, and the
|
|
28
30
|
# editor's C# operations as the kernel's catalog run wrote them.
|
|
@@ -45,10 +47,11 @@ readme = {file = "docs/README.md", content-type = "text/markdown"}
|
|
|
45
47
|
[tool.setuptools]
|
|
46
48
|
# The Python toolkit alone: the Unity package (com.m3trik.unitytk/, beside it)
|
|
47
49
|
# is installed into a project by Unity's Package Manager, never by pip.
|
|
48
|
-
packages = ["unitytk"]
|
|
50
|
+
packages = ["unitytk", "unitytk.sheets"]
|
|
49
51
|
|
|
50
52
|
[tool.setuptools.package-data]
|
|
51
53
|
"unitytk" = ["*.json"]
|
|
54
|
+
"unitytk.sheets" = ["clauses/*.json", "readings/*.json", "*.md"] # *.md: the reader's rules, read where the code is
|
|
52
55
|
|
|
53
56
|
[tool.m3trik.layers.csharp]
|
|
54
57
|
# CODE_STANDARD section 0 (Parts): the Unity package's assemblies, top first. An
|
|
@@ -60,6 +63,11 @@ packages = ["unitytk"]
|
|
|
60
63
|
# the generated *.g.cs) against frozen baselines of today's exceptions.
|
|
61
64
|
root = "com.m3trik.unitytk"
|
|
62
65
|
order = [
|
|
66
|
+
# Kits: recipes over several features' actions, the one part that composes
|
|
67
|
+
# features (through their public API alone); its tests over it. A kit is
|
|
68
|
+
# editor composition alone: no runtime part, so a component is a feature's.
|
|
69
|
+
"Kits/*/Tests",
|
|
70
|
+
"Kits/*/Editor",
|
|
63
71
|
# Tools: menus and windows over the features' actions.
|
|
64
72
|
"Tools/*",
|
|
65
73
|
# Each feature's assemblies, peers of every other feature's: its tests,
|
|
@@ -48,7 +48,8 @@ _SELF = os.path.basename(__file__)
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def _source_files(*suffixes, exclude=()):
|
|
51
|
-
"""Yield
|
|
51
|
+
"""Yield the repo's source paths a commit would hold (tracked, or new and
|
|
52
|
+
not ignored: never a test project's ``Library``), skipping generated trees.
|
|
52
53
|
|
|
53
54
|
Args:
|
|
54
55
|
suffixes (str): File extensions to yield.
|
|
@@ -57,11 +58,34 @@ def _source_files(*suffixes, exclude=()):
|
|
|
57
58
|
its own docstring.
|
|
58
59
|
"""
|
|
59
60
|
skip = {_SELF, *exclude}
|
|
61
|
+
for path in _committable_paths():
|
|
62
|
+
name = os.path.basename(path)
|
|
63
|
+
if name.endswith(suffixes) and name not in skip:
|
|
64
|
+
yield path
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _committable_paths():
|
|
68
|
+
"""Every file a commit would hold, from git; outside a repository (an
|
|
69
|
+
unpacked sdist) every file, :data:`_SKIP_DIRS` left out."""
|
|
70
|
+
import subprocess
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
listed = subprocess.run(
|
|
74
|
+
["git", "-C", REPO_ROOT, "ls-files", "--cached", "--others", "--exclude-standard", "-z"],
|
|
75
|
+
capture_output=True, text=True, encoding="utf-8", check=True,
|
|
76
|
+
).stdout.split("\0")
|
|
77
|
+
except (OSError, subprocess.CalledProcessError):
|
|
78
|
+
listed = None
|
|
79
|
+
if listed is not None:
|
|
80
|
+
for rel in listed:
|
|
81
|
+
path = os.path.normpath(os.path.join(REPO_ROOT, rel))
|
|
82
|
+
if rel and not _SKIP_DIRS.intersection(rel.split("/")) and os.path.isfile(path):
|
|
83
|
+
yield path
|
|
84
|
+
return
|
|
60
85
|
for dirpath, dirnames, filenames in os.walk(REPO_ROOT):
|
|
61
86
|
dirnames[:] = [d for d in dirnames if d not in _SKIP_DIRS]
|
|
62
87
|
for name in filenames:
|
|
63
|
-
|
|
64
|
-
yield os.path.join(dirpath, name)
|
|
88
|
+
yield os.path.join(dirpath, name)
|
|
65
89
|
|
|
66
90
|
|
|
67
91
|
def _run_case(case_cls):
|
|
@@ -338,6 +362,38 @@ class UnityEnvTest(unittest.TestCase):
|
|
|
338
362
|
none, _ = case(make)
|
|
339
363
|
self.assertEqual(EnvSkip.tally(none), {EnvSkip.reason(UnityEnv.NO_EDITOR): 1})
|
|
340
364
|
|
|
365
|
+
def test_a_full_drive_skips_saying_so_not_as_a_licence_or_template_fault(self):
|
|
366
|
+
"""Measured 2026-11-24: the repo's drive at 327 MB free, Unity's package
|
|
367
|
+
import died on ENOSPC, and the run blamed "typically no batch-mode
|
|
368
|
+
license". A drive without room for a project is said as that, before
|
|
369
|
+
Unity starts, on the one check's type (``UnityProject.NoRoom``); a
|
|
370
|
+
failure Unity itself reports is its own, never read off its words."""
|
|
371
|
+
from unitytk.unity_cli import UnityCli
|
|
372
|
+
|
|
373
|
+
import pythontk as ptk
|
|
374
|
+
|
|
375
|
+
store = ptk.TempArtifacts("unitytk_create_project", policy="scoped")
|
|
376
|
+
self.addCleanup(store.cleanup)
|
|
377
|
+
project = os.path.join(store.dir_path(), "p")
|
|
378
|
+
|
|
379
|
+
class Case(unittest.TestCase):
|
|
380
|
+
def test_create(self):
|
|
381
|
+
UnityEnv.create_project(self, project)
|
|
382
|
+
|
|
383
|
+
self._editors({"6000.3.10f1": "C:/U/6000/Unity.exe"})
|
|
384
|
+
full = mock.Mock(free=UnityProject.ROOM_BYTES - 1)
|
|
385
|
+
roomy = mock.Mock(free=UnityProject.ROOM_BYTES * 4)
|
|
386
|
+
with mock.patch.dict(os.environ, {UnityEnv.EDITOR_VAR: ""}):
|
|
387
|
+
with mock.patch.object(UnityCli, "create_project") as made, mock.patch("shutil.disk_usage", return_value=full):
|
|
388
|
+
before = _run_case(Case)
|
|
389
|
+
self.assertFalse(made.called, "no Unity started on a drive without room")
|
|
390
|
+
self.assertEqual(EnvSkip.tally(before), {UnityEnv.no_room_reason(): 1})
|
|
391
|
+
enospc = RuntimeError("unity projects new failed: ... -- the log says: com.unity.burst: ENOSPC: no space left on device")
|
|
392
|
+
with mock.patch.object(UnityCli, "create_project", side_effect=enospc), mock.patch("shutil.disk_usage", return_value=roomy):
|
|
393
|
+
after = _run_case(Case)
|
|
394
|
+
self.assertEqual(EnvSkip.tally(after), {UnityEnv.project_creation_reason(): 1},
|
|
395
|
+
"room checked first: what Unity says after is its own failure")
|
|
396
|
+
|
|
341
397
|
def test_a_named_editor_the_cli_does_not_list_makes_no_project(self):
|
|
342
398
|
"""An executable the CLI does not list has no version to make with, so
|
|
343
399
|
the CLI made the project with its default editor while :meth:`run`
|
|
@@ -529,6 +585,14 @@ class UnityEnvTest(unittest.TestCase):
|
|
|
529
585
|
with self.subTest(project=project):
|
|
530
586
|
self.assertLessEqual(len(project), budget, project)
|
|
531
587
|
|
|
588
|
+
def test_the_base_is_the_named_one_else_the_repos_and_probes_no_drive(self):
|
|
589
|
+
"""``UNITYTK_TEMP_PROJECTS`` names the base, else the repo's own; no drive
|
|
590
|
+
is probed to choose (a drive without room is said where a project is
|
|
591
|
+
made: ``UnityProject.NoRoom``). Added: 2026-11-24"""
|
|
592
|
+
with mock.patch.object(UnityProject, "free_bytes", side_effect=AssertionError("probed")):
|
|
593
|
+
self.assertEqual(TempProjects.base_for({}), TempProjects.DEFAULT_BASE)
|
|
594
|
+
self.assertEqual(TempProjects.base_for({"UNITYTK_TEMP_PROJECTS": "D:/mine"}), "D:/mine")
|
|
595
|
+
|
|
532
596
|
|
|
533
597
|
class SuiteOptionsTest(unittest.TestCase):
|
|
534
598
|
"""The opt-in switches are named once, neutrally."""
|
|
@@ -640,6 +704,27 @@ def _client_denylist():
|
|
|
640
704
|
sys.path.remove(scripts)
|
|
641
705
|
|
|
642
706
|
|
|
707
|
+
class SourceFilesTest(unittest.TestCase):
|
|
708
|
+
"""The scans read the source a commit would hold: never a test project's
|
|
709
|
+
copy of a package (an integration suite's ``Library``, git-ignored), which
|
|
710
|
+
is someone else's code."""
|
|
711
|
+
|
|
712
|
+
def test_a_file_git_ignores_is_no_source_and_the_packages_own_is(self):
|
|
713
|
+
import pythontk as ptk
|
|
714
|
+
|
|
715
|
+
store = ptk.TempArtifacts(
|
|
716
|
+
"unitytk_source_probe", policy="scoped", dir=os.path.join(REPO_ROOT, "tests", "temp_unity")
|
|
717
|
+
)
|
|
718
|
+
self.addCleanup(store.cleanup)
|
|
719
|
+
probe = os.path.join(store.dir_path(), "Library", "PackageCache", "Probe.cs")
|
|
720
|
+
os.makedirs(os.path.dirname(probe))
|
|
721
|
+
open(probe, "w").close()
|
|
722
|
+
found = {os.path.normcase(os.path.normpath(p)) for p in _source_files(".cs")}
|
|
723
|
+
self.assertNotIn(os.path.normcase(os.path.normpath(probe)), found)
|
|
724
|
+
own = os.path.join(REPO_ROOT, "com.m3trik.unitytk", "Kernel", "Runtime", "CameraDrawing.cs")
|
|
725
|
+
self.assertIn(os.path.normcase(os.path.normpath(own)), found)
|
|
726
|
+
|
|
727
|
+
|
|
643
728
|
class PublicHygieneTest(unittest.TestCase):
|
|
644
729
|
"""Client program identifiers stay out of tracked Python/C# source.
|
|
645
730
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# !/usr/bin/python
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
"""The indicator glow's two twins hold one rule.
|
|
4
|
+
|
|
5
|
+
An indicator light is drawn a glow card by every runtime that reads a
|
|
6
|
+
delivery's indicators: the WebXR viewer (pythontk's
|
|
7
|
+
``net_utils/preview/kernel/indicators.js``) and the Unity package
|
|
8
|
+
(``RenderEffects/Runtime/IndicatorGlow.cs``), whose summary says it draws the
|
|
9
|
+
same. Nothing held them to it: the C# restated the viewer's least on-screen
|
|
10
|
+
size, halo and lit threshold by hand. These read both files and compare: the
|
|
11
|
+
three constants, the card added over the scene as the viewer's additive
|
|
12
|
+
blending draws it, and the light's size measured the same way (its mesh's
|
|
13
|
+
bounding sphere times its largest world scale).
|
|
14
|
+
"""
|
|
15
|
+
import importlib.util
|
|
16
|
+
import os
|
|
17
|
+
import re
|
|
18
|
+
import unittest
|
|
19
|
+
|
|
20
|
+
_PACKAGE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "com.m3trik.unitytk")
|
|
21
|
+
CSHARP = os.path.join(_PACKAGE, "Features", "RenderEffects", "Runtime", "IndicatorGlow.cs")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _viewer() -> str:
|
|
25
|
+
"""The viewer's twin, where pythontk (unitytk's automation's one dependency) holds it."""
|
|
26
|
+
spec = importlib.util.find_spec("pythontk")
|
|
27
|
+
if spec is None or not spec.submodule_search_locations:
|
|
28
|
+
raise AssertionError("pythontk is not importable: install unitytk's dependencies")
|
|
29
|
+
return os.path.join(list(spec.submodule_search_locations)[0], "net_utils", "preview", "kernel", "indicators.js")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _read(path: str) -> str:
|
|
33
|
+
with open(path, encoding="utf-8") as handle:
|
|
34
|
+
return handle.read()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _js_constant(text: str, name: str) -> float:
|
|
38
|
+
match = re.search(rf"\bconst\s+{name}\s*=\s*([0-9.]+)\s*;", text)
|
|
39
|
+
if match is None:
|
|
40
|
+
raise AssertionError(f"indicators.js declares no {name}: the viewer's rule moved; read it again")
|
|
41
|
+
return float(match.group(1))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _cs_constant(text: str, name: str) -> float:
|
|
45
|
+
match = re.search(rf"\bconst\s+float\s+{name}\s*=\s*([0-9.]+)f?\s*;", text)
|
|
46
|
+
if match is None:
|
|
47
|
+
raise AssertionError(f"IndicatorGlow.cs declares no {name}")
|
|
48
|
+
return float(match.group(1))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class TestIndicatorGlowTwin(unittest.TestCase):
|
|
52
|
+
def setUp(self):
|
|
53
|
+
self.js = _read(_viewer())
|
|
54
|
+
self.cs = _read(CSHARP)
|
|
55
|
+
|
|
56
|
+
def test_its_constants_are_the_viewers(self):
|
|
57
|
+
"""The least on-screen size, the halo and the lit threshold: one value
|
|
58
|
+
each, on both sides. Added: 2026-11-26"""
|
|
59
|
+
for js, cs in (("MIN_PIXELS", "MinPixels"), ("HALO", "Halo"), ("LIT", "LitAbove")):
|
|
60
|
+
with self.subTest(constant=js):
|
|
61
|
+
self.assertEqual(_cs_constant(self.cs, cs), _js_constant(self.js, js))
|
|
62
|
+
|
|
63
|
+
def test_the_card_is_added_over_the_scene_as_the_viewers(self):
|
|
64
|
+
"""The viewer adds its card (``THREE.AdditiveBlending``); the package asks
|
|
65
|
+
its pipeline's additive switch. Added: 2026-11-26"""
|
|
66
|
+
self.assertIn("THREE.AdditiveBlending", self.js)
|
|
67
|
+
self.assertRegex(self.cs, r"\.SetAdditive\(")
|
|
68
|
+
|
|
69
|
+
def test_a_lights_size_is_measured_as_the_viewer_measures_it(self):
|
|
70
|
+
"""The viewer's radius is its mesh's bounding sphere times its largest
|
|
71
|
+
world scale; the package's must be too, never its box's half-diagonal.
|
|
72
|
+
Added: 2026-11-26"""
|
|
73
|
+
self.assertIn("boundingSphere.radius", self.js)
|
|
74
|
+
self.assertRegex(self.js, r"radius\s*\*\s*Math\.max\(scale\.x,\s*scale\.y,\s*scale\.z\)")
|
|
75
|
+
self.assertRegex(self.cs, r"local\.radius\s*\*\s*Mathf\.Max\(")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
unittest.main()
|
|
@@ -9,6 +9,7 @@ import sys
|
|
|
9
9
|
import tempfile
|
|
10
10
|
import unittest
|
|
11
11
|
from pathlib import Path
|
|
12
|
+
from types import SimpleNamespace
|
|
12
13
|
from unittest.mock import patch
|
|
13
14
|
|
|
14
15
|
try:
|
|
@@ -21,6 +22,7 @@ import pythontk as ptk
|
|
|
21
22
|
|
|
22
23
|
from unitytk.project_builder import ProjectBuilder
|
|
23
24
|
from unitytk.unity_cli import UnityCli
|
|
25
|
+
from unitytk.unity_project import UnityProject
|
|
24
26
|
|
|
25
27
|
RESULTS = """<?xml version="1.0" encoding="utf-8"?>
|
|
26
28
|
<test-run result="Failed(Child)">
|
|
@@ -44,6 +46,27 @@ NOTHING = """<?xml version="1.0" encoding="utf-8"?>
|
|
|
44
46
|
"""
|
|
45
47
|
|
|
46
48
|
|
|
49
|
+
def _pipeline_asset(project, name, body: bytes, quality: bool = False) -> Path:
|
|
50
|
+
"""A URP pipeline asset at ``Assets/Settings/<name>.asset`` with its
|
|
51
|
+
``.meta``, named by the project's graphics settings (*quality*: by a
|
|
52
|
+
quality level, as a template's PC and Mobile assets are)."""
|
|
53
|
+
import uuid
|
|
54
|
+
|
|
55
|
+
settings = Path(project, "Assets", "Settings")
|
|
56
|
+
settings.mkdir(parents=True, exist_ok=True)
|
|
57
|
+
asset = settings / f"{name}.asset"
|
|
58
|
+
asset.write_bytes(body)
|
|
59
|
+
guid = uuid.uuid4().hex
|
|
60
|
+
(settings / f"{name}.asset.meta").write_text(f"fileFormatVersion: 2\nguid: {guid}\n", encoding="utf-8")
|
|
61
|
+
which = "QualitySettings.asset" if quality else "GraphicsSettings.asset"
|
|
62
|
+
key = "customRenderPipeline" if quality else "m_CustomRenderPipeline"
|
|
63
|
+
path = Path(project, "ProjectSettings", which)
|
|
64
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
65
|
+
with path.open("a", encoding="utf-8") as fh:
|
|
66
|
+
fh.write(f" {key}: {{fileID: 11400000, guid: {guid}, type: 2}}\n")
|
|
67
|
+
return asset
|
|
68
|
+
|
|
69
|
+
|
|
47
70
|
def _made_by_cli(path, version=None, template=None, timeout=None, cancel=None):
|
|
48
71
|
"""What ``unity projects new`` leaves: an imported project with a manifest."""
|
|
49
72
|
folder = Path(path)
|
|
@@ -224,6 +247,18 @@ class TestProjectBuilder(UnityTkTestCase):
|
|
|
224
247
|
made.assert_not_called()
|
|
225
248
|
self.assertTrue((folder / "notes.txt").is_file())
|
|
226
249
|
|
|
250
|
+
def test_a_drive_without_room_for_a_project_is_refused_before_unity_starts(self):
|
|
251
|
+
"""Measured 2026-11-24: a drive at 327 MB free let Unity's CLI run two
|
|
252
|
+
minutes and die in its package import (ENOSPC). Added: 2026-11-24"""
|
|
253
|
+
full = SimpleNamespace(free=UnityProject.ROOM_BYTES - 1)
|
|
254
|
+
with patch.object(UnityCli, "create_project", side_effect=_made_by_cli) as made, patch(
|
|
255
|
+
"shutil.disk_usage", return_value=full
|
|
256
|
+
):
|
|
257
|
+
with self.assertRaisesRegex(UnityProject.NoRoom, r"GB free.*UNITYTK_TEMP_PROJECTS"):
|
|
258
|
+
ProjectBuilder.build()
|
|
259
|
+
made.assert_not_called()
|
|
260
|
+
self.assertFalse(ProjectBuilder.folder("6000.3.10f1").exists())
|
|
261
|
+
|
|
227
262
|
def test_a_failed_make_takes_away_only_what_it_made(self):
|
|
228
263
|
"""Added: 2026-11-08"""
|
|
229
264
|
def fails(path, **_):
|
|
@@ -411,6 +446,108 @@ class TestProjectBuilder(UnityTkTestCase):
|
|
|
411
446
|
imported = {node.module for node in ast.walk(tree) if isinstance(node, ast.ImportFrom) and node.module}
|
|
412
447
|
self.assertNotIn("unitytk.unity_host", imported)
|
|
413
448
|
|
|
449
|
+
def test_its_urp_pipeline_assets_smooth_their_edges_asked_first_once(self):
|
|
450
|
+
"""The URP template ships MSAA off: each pipeline asset gets 4x, its line
|
|
451
|
+
endings kept, a plan writes nothing, a second run writes nothing.
|
|
452
|
+
Added: 2026-11-21"""
|
|
453
|
+
project = self.cache / "proj"
|
|
454
|
+
pc = _pipeline_asset(project, "PC_RPAsset", b"MonoBehaviour:\r\n m_RendererDataList:\r\n - {fileID: 1}\r\n m_MSAA: 1\r\n m_RenderScale: 1\r\n",
|
|
455
|
+
quality=True)
|
|
456
|
+
other = project / "Assets" / "Settings" / "Volume.asset"
|
|
457
|
+
other.write_bytes(b"MonoBehaviour:\n m_MSAA: 1\n")
|
|
458
|
+
plan = ptk.OpContext(dry_run=True)
|
|
459
|
+
self.assertEqual(ProjectBuilder.tune_pipeline(project, plan), [str(pc)])
|
|
460
|
+
self.assertIn(b"m_MSAA: 1", pc.read_bytes(), "a plan writes nothing")
|
|
461
|
+
self.assertEqual(ProjectBuilder.tune_pipeline(project), [str(pc)])
|
|
462
|
+
self.assertIn(b" m_MSAA: 4\r\n m_RenderScale: 1\r\n", pc.read_bytes())
|
|
463
|
+
self.assertEqual(other.read_bytes(), b"MonoBehaviour:\n m_MSAA: 1\n", "no pipeline asset: left as it is")
|
|
464
|
+
self.assertEqual(ProjectBuilder.tune_pipeline(project), [], "set already")
|
|
465
|
+
|
|
466
|
+
def test_the_owned_project_is_tuned_and_a_keyed_one_keeps_its_rendering_unless_asked(self):
|
|
467
|
+
"""``build`` tuned every project's rendering, a person's keyed play
|
|
468
|
+
project included; now the owned project by default, a keyed one only
|
|
469
|
+
with ``tuned=True``, and ``tuned=False`` leaves the owned one alone.
|
|
470
|
+
Added: 2026-11-24"""
|
|
471
|
+
|
|
472
|
+
def made(path, **kwargs):
|
|
473
|
+
folder = Path(_made_by_cli(path, **kwargs))
|
|
474
|
+
_pipeline_asset(folder, "PC_RPAsset", b"MonoBehaviour:\n m_RendererDataList:\n - {fileID: 1}\n m_MSAA: 1\n")
|
|
475
|
+
return str(folder)
|
|
476
|
+
|
|
477
|
+
def msaa(folder):
|
|
478
|
+
return Path(folder, "Assets", "Settings", "PC_RPAsset.asset").read_bytes()
|
|
479
|
+
|
|
480
|
+
with patch.object(UnityCli, "create_project", side_effect=made), patch.object(ProjectBuilder, "import_samples"):
|
|
481
|
+
owned = ProjectBuilder.build()
|
|
482
|
+
self.assertIn(b"m_MSAA: 4", msaa(owned), "the owned project: tuned")
|
|
483
|
+
keyed = ProjectBuilder.build(key="play")
|
|
484
|
+
self.assertIn(b"m_MSAA: 1", msaa(keyed), "a keyed project's rendering: its own")
|
|
485
|
+
ProjectBuilder.build(key="play", tuned=True)
|
|
486
|
+
self.assertIn(b"m_MSAA: 4", msaa(keyed), "tuned where asked")
|
|
487
|
+
Path(owned, "Assets", "Settings", "PC_RPAsset.asset").write_bytes(msaa(owned).replace(b"m_MSAA: 4", b"m_MSAA: 2"))
|
|
488
|
+
ProjectBuilder.build(tuned=False)
|
|
489
|
+
self.assertIn(b"m_MSAA: 2", msaa(owned), "left alone where asked")
|
|
490
|
+
|
|
491
|
+
def test_the_tuning_is_its_parameters(self):
|
|
492
|
+
"""Each tuned setting is a parameter, today's values its defaults.
|
|
493
|
+
Added: 2026-11-24"""
|
|
494
|
+
project = self.cache / "proj"
|
|
495
|
+
pc = _pipeline_asset(project, "PC_RPAsset", b"MonoBehaviour:\n m_RendererDataList:\n - {fileID: 1}\n m_MSAA: 1\n")
|
|
496
|
+
written = ProjectBuilder.tune_pipeline(project, pipeline_settings={"m_MSAA": "8"})
|
|
497
|
+
self.assertEqual(written, [str(pc)])
|
|
498
|
+
self.assertIn(b"m_MSAA: 8", pc.read_bytes())
|
|
499
|
+
|
|
500
|
+
def test_a_project_is_muted_asked_first_once_and_can_sound_again(self):
|
|
501
|
+
"""Tests and agent sessions run unattended: the global volume goes to 0
|
|
502
|
+
(sources still play, so audio tests hold), line endings kept, a plan
|
|
503
|
+
writes nothing, a second run writes nothing; ``muted=False`` undoes it.
|
|
504
|
+
Added: 2026-11-21"""
|
|
505
|
+
project = self.cache / "proj"
|
|
506
|
+
(project / "ProjectSettings").mkdir(parents=True)
|
|
507
|
+
audio = project / "ProjectSettings" / "AudioManager.asset"
|
|
508
|
+
audio.write_bytes(b"AudioManager:\r\n m_Volume: 1\r\n m_DisableAudio: 0\r\n")
|
|
509
|
+
self.assertEqual(ProjectBuilder.mute(project, ctx=ptk.OpContext(dry_run=True)), [str(audio)])
|
|
510
|
+
self.assertIn(b"m_Volume: 1\r\n", audio.read_bytes(), "a plan writes nothing")
|
|
511
|
+
self.assertEqual(ProjectBuilder.mute(project), [str(audio)])
|
|
512
|
+
self.assertEqual(audio.read_bytes(), b"AudioManager:\r\n m_Volume: 0\r\n m_DisableAudio: 0\r\n")
|
|
513
|
+
self.assertEqual(ProjectBuilder.mute(project), [], "muted already")
|
|
514
|
+
self.assertEqual(ProjectBuilder.mute(project, muted=False), [str(audio)])
|
|
515
|
+
self.assertIn(b"m_Volume: 1\r\n", audio.read_bytes())
|
|
516
|
+
self.assertEqual(ProjectBuilder.mute(self.cache / "none"), [], "no project: nothing")
|
|
517
|
+
|
|
518
|
+
def test_the_pipeline_assets_are_those_the_settings_name_and_no_other(self):
|
|
519
|
+
"""``tune_pipeline`` read every ``*.asset`` under ``Assets`` to find the
|
|
520
|
+
pipeline assets; they are the ones the graphics and quality settings
|
|
521
|
+
name, by GUID, and an asset that only looks like one (a copy no setting
|
|
522
|
+
names, a sample's) is left as it is. Added: 2026-11-24"""
|
|
523
|
+
project = self.cache / "proj"
|
|
524
|
+
body = b"MonoBehaviour:\n m_RendererDataList:\n - {fileID: 1}\n m_MSAA: 1\n"
|
|
525
|
+
drawn = _pipeline_asset(project, "PC_RPAsset", body)
|
|
526
|
+
level = _pipeline_asset(project, "Mobile_RPAsset", body, quality=True)
|
|
527
|
+
unnamed = Path(project, "Assets", "Samples", "Copy_RPAsset.asset")
|
|
528
|
+
unnamed.parent.mkdir(parents=True)
|
|
529
|
+
unnamed.write_bytes(body)
|
|
530
|
+
self.assertEqual(ProjectBuilder.pipeline_assets(project), sorted([drawn, level]))
|
|
531
|
+
self.assertEqual(sorted(ProjectBuilder.tune_pipeline(project)), sorted([str(drawn), str(level)]))
|
|
532
|
+
self.assertEqual(unnamed.read_bytes(), body, "no setting names it: left as it is")
|
|
533
|
+
self.assertEqual(ProjectBuilder.pipeline_assets(self.cache / "none"), [], "no project: none")
|
|
534
|
+
|
|
535
|
+
def test_its_urp_renderers_keep_the_templates_settings(self):
|
|
536
|
+
"""A tuned project's renderers stay as its template made them (its
|
|
537
|
+
path, its screen-space occlusion): what a delivery needs of them, the
|
|
538
|
+
package's own checks name, as in a person's project. Added: 2026-11-24"""
|
|
539
|
+
project = self.cache / "proj"
|
|
540
|
+
settings = project / "Assets" / "Settings"
|
|
541
|
+
settings.mkdir(parents=True)
|
|
542
|
+
renderer = settings / "PC_Renderer.asset"
|
|
543
|
+
made = (
|
|
544
|
+
b"--- !u!114 &1\r\nMonoBehaviour:\r\n m_Name: PC_Renderer\r\n m_RendererFeatures:\r\n - {fileID: 2}\r\n m_RenderingMode: 2\r\n"
|
|
545
|
+
b"--- !u!114 &2\r\nMonoBehaviour:\r\n m_Name: ScreenSpaceAmbientOcclusion\r\n m_Active: 1\r\n"
|
|
546
|
+
)
|
|
547
|
+
renderer.write_bytes(made)
|
|
548
|
+
self.assertEqual(ProjectBuilder.tune_pipeline(project), [])
|
|
549
|
+
self.assertEqual(renderer.read_bytes(), made, "its Forward+ path and its occlusion kept")
|
|
550
|
+
|
|
414
551
|
|
|
415
552
|
class TestSampleImport(UnityTkTestCase):
|
|
416
553
|
"""The package's samples, copied in where the Package Manager imports
|
|
@@ -503,6 +640,30 @@ class TestSampleImport(UnityTkTestCase):
|
|
|
503
640
|
self.assertTrue(self._imported("1.3.0").is_dir())
|
|
504
641
|
self.assertFalse(self._imported("1.2.0").parent.exists(), "one version's assemblies, never two")
|
|
505
642
|
|
|
643
|
+
def test_a_sample_the_package_no_longer_lists_leaves_and_a_folder_it_did_not_copy_stays(self):
|
|
644
|
+
"""Bug: a sample the package renamed stayed in the owned project beside the new one, its recipe
|
|
645
|
+
no longer compiling: every editor run failed on it. Fixed: 2026-11-25"""
|
|
646
|
+
ProjectBuilder.import_samples(self.project, self.package)
|
|
647
|
+
own = self._imported().parent / "Mine" # a folder a person made there: no stamp, not the builder's
|
|
648
|
+
own.mkdir()
|
|
649
|
+
(own / "Notes.txt").write_text("kept", encoding="utf-8")
|
|
650
|
+
(self.source.parent / "Demo").rename(self.source.parent / "Tour")
|
|
651
|
+
(self.package / "package.json").write_text(
|
|
652
|
+
json.dumps({"name": "com.example.pkg", "version": "1.2.0", "displayName": "Pkg",
|
|
653
|
+
"samples": [{"displayName": "Tour", "description": "d", "path": "Samples~/Tour"}]}),
|
|
654
|
+
encoding="utf-8",
|
|
655
|
+
)
|
|
656
|
+
Path(str(self._imported()) + ".meta").write_text("fileFormatVersion: 2\n", encoding="utf-8")
|
|
657
|
+
plan = ptk.OpContext(dry_run=True)
|
|
658
|
+
ProjectBuilder.import_samples(self.project, self.package, ctx=plan)
|
|
659
|
+
self.assertEqual([c.kind for c in plan.changes], ["delete", "write"], "the sample that left, then the one that came")
|
|
660
|
+
self.assertTrue(self._imported().is_dir(), "a dry run removes nothing")
|
|
661
|
+
ProjectBuilder.import_samples(self.project, self.package)
|
|
662
|
+
self.assertFalse(self._imported().exists(), "the sample the package no longer lists is gone")
|
|
663
|
+
self.assertFalse(Path(str(self._imported()) + ".meta").exists(), "with its meta")
|
|
664
|
+
self.assertTrue((self._imported().parent / "Tour" / "Editor" / "Recipe.cs").is_file())
|
|
665
|
+
self.assertTrue((own / "Notes.txt").is_file(), "what the builder did not copy stays")
|
|
666
|
+
|
|
506
667
|
def test_a_dry_run_plans_the_copy_and_writes_nothing(self):
|
|
507
668
|
ctx = ptk.OpContext(dry_run=True)
|
|
508
669
|
self.assertEqual(ProjectBuilder.import_samples(self.project, self.package, ctx=ctx), [])
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# !/usr/bin/python
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
"""Tests for the Tasks sample's task (``com.m3trik.unitytk/Samples~/Tasks``):
|
|
4
|
+
unitytk's reader reads every row of its sheet against its delivery into what the
|
|
5
|
+
kit builds. The task is written by the workspace's sample sync (its recipe,
|
|
6
|
+
``m3trik/scripts/unity_samples/tasks.py``, which holds the files to it)."""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
import unittest
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from .base_test import UnityTkTestCase
|
|
15
|
+
except ImportError:
|
|
16
|
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
17
|
+
from base_test import UnityTkTestCase
|
|
18
|
+
|
|
19
|
+
import pythontk as ptk
|
|
20
|
+
|
|
21
|
+
from unitytk.sheets import SheetCheck, SheetPlan
|
|
22
|
+
|
|
23
|
+
#: The committed task: the Tasks sample's sheet, delivery and plan.
|
|
24
|
+
FOLDER = (
|
|
25
|
+
Path(__file__).resolve().parent.parent
|
|
26
|
+
/ "com.m3trik.unitytk"
|
|
27
|
+
/ "Samples~"
|
|
28
|
+
/ "Tasks"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SampleTaskTestCase(UnityTkTestCase):
|
|
33
|
+
def test_every_row_reads_and_every_take_is_played(self):
|
|
34
|
+
plan = SheetPlan.load(FOLDER / "cabinet.plan.json")
|
|
35
|
+
self.assertEqual(list(plan.actions("unread")), [])
|
|
36
|
+
self.assertEqual(
|
|
37
|
+
[a.text for a in plan.actions("note")],
|
|
38
|
+
["The cabinet stands in front of you with its tools on the table."],
|
|
39
|
+
"the intro's prose, a note",
|
|
40
|
+
)
|
|
41
|
+
self.assertEqual(plan.issues, [])
|
|
42
|
+
self.assertEqual(sum(len(a.issues) for a in plan.actions()), 0)
|
|
43
|
+
takes = list(ptk.FbxFile.load(str(FOLDER / "cabinet.fbx")).take_names())
|
|
44
|
+
self.assertEqual(
|
|
45
|
+
[a.clip for a in plan.actions() if a.clip],
|
|
46
|
+
takes,
|
|
47
|
+
"each take played once, in order",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def test_the_plan_is_what_the_reader_makes_of_the_sheet_and_the_delivery(self):
|
|
51
|
+
fresh = Path(self.create_temp_dir()) / "cabinet.plan.json"
|
|
52
|
+
SheetPlan.from_sheet(
|
|
53
|
+
str(FOLDER / "cabinet.csv"),
|
|
54
|
+
str(FOLDER / "cabinet.fbx"),
|
|
55
|
+
mapping="interactive",
|
|
56
|
+
).write(fresh)
|
|
57
|
+
self.assertEqual(
|
|
58
|
+
fresh.read_bytes(),
|
|
59
|
+
(FOLDER / "cabinet.plan.json").read_bytes(),
|
|
60
|
+
"stale: run python m3trik/scripts/sync_unity_samples.py",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def test_the_sheet_is_in_the_interactive_format_and_passes_its_strict_check(self):
|
|
64
|
+
check = SheetCheck.run(str(FOLDER / "cabinet.csv"), str(FOLDER / "cabinet.fbx"))
|
|
65
|
+
self.assertEqual([i.line() for i in check.errors], [])
|
|
66
|
+
self.assertTrue(check.strict and check.passed)
|
|
67
|
+
|
|
68
|
+
def test_the_fbx_meta_names_its_importer_so_unity_reads_a_new_model(self):
|
|
69
|
+
meta = (FOLDER / "cabinet.fbx.meta").read_text(encoding="utf-8")
|
|
70
|
+
self.assertIn("ModelImporter:\n serializedVersion: 24200", meta)
|
|
71
|
+
|
|
72
|
+
def test_the_kits_node_fields_are_every_node_the_reading_binds(self):
|
|
73
|
+
"""The Tasks kit's rows' node fields (``TaskBehaviorAttribute``'s default ``NodeFields``, which a
|
|
74
|
+
manifest's assessment finds as it finds targets) restate the built-in clause templates' node groups and the
|
|
75
|
+
reading's hand and arrows: a group left out there is a node name never checked (a teleport's ``side_of``)."""
|
|
76
|
+
import re
|
|
77
|
+
|
|
78
|
+
from unitytk.sheets import ClauseBook, ReadingSpec
|
|
79
|
+
|
|
80
|
+
kit = FOLDER.parent.parent / "Kits" / "Tasks" / "Editor"
|
|
81
|
+
fields = dict(
|
|
82
|
+
re.findall(
|
|
83
|
+
r'(\w+) = "(\w+)"',
|
|
84
|
+
re.search(
|
|
85
|
+
r"class Fields\s*\{\s*internal const string ([^;]+);",
|
|
86
|
+
(kit / "TaskKit.cs").read_text(encoding="utf-8"),
|
|
87
|
+
).group(1),
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
declared = re.search(
|
|
91
|
+
r"NodeFields = new\[\] \{([^}]*)\}",
|
|
92
|
+
(kit / "TaskBehaviorAttribute.cs").read_text(encoding="utf-8"),
|
|
93
|
+
).group(1)
|
|
94
|
+
node_fields = {fields[name] for name in re.findall(r"Fields\.(\w+)", declared)}
|
|
95
|
+
reading = ReadingSpec.load("interactive")
|
|
96
|
+
bound = {g for _, spec in ClauseBook.load_templates() for g in spec.nodes or []}
|
|
97
|
+
# And each node a cell row's word binds (a teleport's `faces`: what its row says the user is brought to face).
|
|
98
|
+
celled = {name for cases in (reading.words or {}).values() for case in cases for name in case.get("nodes") or {}}
|
|
99
|
+
self.assertEqual(node_fields, bound | celled | {reading.hand, reading.arrows})
|
|
100
|
+
|
|
101
|
+
def test_the_kits_traits_that_restate_a_clause_role_say_the_same(self):
|
|
102
|
+
"""Two of the Tasks kit's traits mean what a clause role means: ``GoesOn`` the role ``continues`` (the step goes
|
|
103
|
+
on by itself), ``Teleports`` the role ``destination`` (the user is brought to the row's place). The kit keeps them
|
|
104
|
+
for a row the manifest adds, which no clause template reads; held here to the built-in templates' roles."""
|
|
105
|
+
import re
|
|
106
|
+
|
|
107
|
+
from unitytk.sheets import ClauseBook
|
|
108
|
+
|
|
109
|
+
behaviors = FOLDER.parent.parent / "Kits" / "Tasks" / "Editor" / "Behaviors"
|
|
110
|
+
source = "\n".join(p.read_text(encoding="utf-8") for p in sorted(behaviors.glob("*.cs")))
|
|
111
|
+
marks = re.findall(r'\[TaskBehavior\("(\w+)"(.*?)\)\]', source, re.S)
|
|
112
|
+
book = ClauseBook()
|
|
113
|
+
for trait, role in (("GoesOn", "continues"), ("Teleports", "destination")):
|
|
114
|
+
with self.subTest(trait=trait):
|
|
115
|
+
self.assertEqual(
|
|
116
|
+
{name for name, rest in marks if re.search(rf"\b{trait} = true\b", rest)},
|
|
117
|
+
book.with_role(role),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
unittest.main()
|