Skip to content

Commit 1faa86d

Browse files
committed
test: update reliability regressions
1 parent 1c285dd commit 1faa86d

3 files changed

Lines changed: 40 additions & 19 deletions

File tree

tests/core/test_default_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ async def test_default_agent(runtime: Runtime):
9797
- No "flexibility" or "configurability" that wasn't requested.
9898
- No error handling for impossible scenarios; validate at boundaries only.
9999
- If a 200-line draft could be 50 lines, rewrite it before showing it.
100-
- Self-check: *"Would a senior engineer call this overcomplicated?"* If yes, simplify.
100+
- Over-fragmentation is overcomplication too: don't scatter logic across many tiny files or extra abstraction layers to satisfy a design pattern. Match the codebase's existing granularity.
101+
- Self-check: *"Would a senior engineer call this overcomplicated or over-engineered?"* If yes, simplify.
101102
102103
**3. Goal-driven execution — define success criteria, then loop until verified.**
103104
- Transform vague tasks into verifiable goals before writing code:

tests/telemetry/test_instrumentation.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,22 @@ def test_queue_overflow_preserves_newest(self):
416416
# ---------------------------------------------------------------------------
417417

418418

419+
def _mock_store_for(runtime: Any) -> MagicMock:
420+
"""A mock BackgroundTaskStore whose ``update_runtime`` runs the callback and
421+
returns the (mutated) runtime, mirroring the real read-modify-write store so
422+
the manager's ``_transition_status`` path is actually exercised."""
423+
store = MagicMock()
424+
store.read_runtime.return_value = runtime
425+
426+
def _update(task_id: str, update_fn: Any) -> Any:
427+
rt = store.read_runtime(task_id)
428+
update_fn(rt)
429+
return rt
430+
431+
store.update_runtime.side_effect = _update
432+
return store
433+
434+
419435
class TestEventPropertyCorrectness:
420436
"""Verify specific events carry the right property types and values."""
421437

@@ -608,8 +624,7 @@ def test_background_task_no_event_without_start_time(self):
608624
from pythinker_code.background.models import TaskRuntime
609625

610626
runtime = TaskRuntime(status="running", started_at=None)
611-
mock_store = MagicMock()
612-
mock_store.read_runtime.return_value = runtime
627+
mock_store = _mock_store_for(runtime)
613628

614629
manager = object.__new__(BackgroundTaskManager)
615630
manager._store = mock_store
@@ -626,8 +641,7 @@ def test_mark_task_killed_emits_completed_event(self):
626641

627642
runtime = TaskRuntime(status="running", started_at=1000.0)
628643

629-
mock_store = MagicMock()
630-
mock_store.read_runtime.return_value = runtime
644+
mock_store = _mock_store_for(runtime)
631645

632646
manager = object.__new__(BackgroundTaskManager)
633647
manager._store = mock_store
@@ -647,8 +661,7 @@ def test_mark_task_killed_no_event_without_start_time(self):
647661
from pythinker_code.background.models import TaskRuntime
648662

649663
runtime = TaskRuntime(status="running", started_at=None)
650-
mock_store = MagicMock()
651-
mock_store.read_runtime.return_value = runtime
664+
mock_store = _mock_store_for(runtime)
652665

653666
manager = object.__new__(BackgroundTaskManager)
654667
manager._store = mock_store

tests/test_release_update_pipeline.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_release_is_promoted_only_after_update_assets_are_ready() -> None:
3636
# Promotion clears prerelease AND marks latest, and only after the wait.
3737
assert "-F prerelease=false" in promote_workflow
3838
assert "-f make_latest=true" in promote_workflow
39-
assert promote_workflow.index("Wait for all release assets") < promote_workflow.index(
39+
assert promote_workflow.index("Wait for install-channel readiness") < promote_workflow.index(
4040
"-F prerelease=false"
4141
)
4242

@@ -67,15 +67,22 @@ def test_install_scripts_gate_on_asset_readiness() -> None:
6767
def test_release_asset_wait_covers_all_updater_channels() -> None:
6868
promote_workflow = (WORKFLOWS / "promote-release.yml").read_text()
6969

70-
for expected_asset_fragment in (
71-
"PythinkerSetup-",
72-
"_amd64.deb",
73-
"_arm64.deb",
74-
".x86_64.rpm",
75-
".aarch64.rpm",
76-
"x86_64-unknown-linux-gnu.tar.gz",
77-
"aarch64-unknown-linux-gnu.tar.gz",
78-
"aarch64-apple-darwin.tar.gz",
79-
"x86_64-apple-darwin.tar.gz",
70+
for expected_readiness_marker in (
71+
"PythinkerSetup-${version}.exe.sha256",
72+
"pythinker-code_${version}_amd64.deb.sha256",
73+
"pythinker-code_${version}_arm64.deb.sha256",
74+
"pythinker-code-${version}.x86_64.rpm.sha256",
75+
"pythinker-code-${version}.aarch64.rpm.sha256",
76+
"pythinker-${version}-x86_64-unknown-linux-gnu.tar.gz.sha256",
77+
"pythinker-${version}-aarch64-unknown-linux-gnu.tar.gz.sha256",
78+
"pythinker-${version}-aarch64-apple-darwin.tar.gz.sha256",
79+
"pythinker-${version}-x86_64-apple-darwin.tar.gz.sha256",
80+
"pythinker-${version}-x86_64-unknown-linux-gnu-onedir.tar.gz.sha256",
81+
"pythinker-${version}-aarch64-unknown-linux-gnu-onedir.tar.gz.sha256",
82+
"pythinker-${version}-aarch64-apple-darwin-onedir.tar.gz.sha256",
83+
"pythinker-${version}-x86_64-apple-darwin-onedir.tar.gz.sha256",
84+
"https://pypi.org/pypi/pythinker-code/${version}/json",
85+
"raw.githubusercontent.com/TechMatrix-labs/homebrew-pythinker",
86+
'version \\"${version}\\"',
8087
):
81-
assert expected_asset_fragment in promote_workflow
88+
assert expected_readiness_marker in promote_workflow

0 commit comments

Comments
 (0)