diff options
Diffstat (limited to 'app/tests/test_taskview.py')
| -rw-r--r-- | app/tests/test_taskview.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/app/tests/test_taskview.py b/app/tests/test_taskview.py index b7f4389..646fccb 100644 --- a/app/tests/test_taskview.py +++ b/app/tests/test_taskview.py @@ -592,5 +592,91 @@ class LanesViewTests(_FakeTui, unittest.TestCase): self.assertLessEqual(x + len(label) - 1, 1 + pane_w - 2) +class SilenceCueTests(_FakeTui, unittest.TestCase): + """The "(no output 6m)" cue for a running step that stopped emitting.""" + + def test_silence_cue_text_format(self): + self.assertEqual(taskview._silence_cue_text(90), "(no output 1m)") + self.assertEqual(taskview._silence_cue_text(3700), "(no output 61m)") + + def test_no_cue_while_output_is_recent(self): + view, _ = self.make_view(steps=[_step("one")]) + view.handle_event({"kind": "step_start", "index": 0, "title": "one"}) + view._ingest_line("working") + self.assertIsNone(taskview._silent_secs(view.last_line_at, + view.last_line_at + 59)) + + def test_cue_after_the_threshold(self): + view, _ = self.make_view(steps=[_step("one")]) + view.handle_event({"kind": "step_start", "index": 0, "title": "one"}) + view._ingest_line("working") + self.assertEqual(taskview._silent_secs(view.last_line_at, + view.last_line_at + 60), 60) + + def test_step_start_resets_and_done_clears_the_tracking(self): + view, _ = self.make_view(steps=[_step("one"), _step("two")]) + view.handle_event({"kind": "step_start", "index": 0, "title": "one"}) + start = view.last_line_at + view.handle_event({"kind": "step_done", "index": 0, "rc": 0}) + self.assertIsNone(view.last_line_at) + view.handle_event({"kind": "step_start", "index": 1, "title": "two"}) + self.assertGreaterEqual(view.last_line_at, start) + + def test_render_shows_the_cue_for_a_silent_step(self): + now = [1000.0] + + def clock(): + return now[0] + + screen = FakeScreen(width=80, height=24) + with patch.object(taskview.TaskView, "_worker_main", + lambda self: None): + view = taskview.TaskView(screen, "Setup", [_step("one")], + clock=clock) + view.handle_event({"kind": "step_start", "index": 0, "title": "one"}) + view._ingest_line("working") + now[0] = view.last_line_at + 300 + view.render() + text = " ".join(t for _, _, t, _ in screen.strings) + self.assertIn("(no output 5m)", text) + + def test_render_hides_the_cue_when_output_is_fresh(self): + now = [1000.0] + + def clock(): + return now[0] + + screen = FakeScreen(width=80, height=24) + with patch.object(taskview.TaskView, "_worker_main", + lambda self: None): + view = taskview.TaskView(screen, "Setup", [_step("one")], + clock=clock) + view.handle_event({"kind": "step_start", "index": 0, "title": "one"}) + view._ingest_line("working") + now[0] = view.last_line_at + 5 + view.render() + text = " ".join(t for _, _, t, _ in screen.strings) + self.assertNotIn("(no output", text) + + def test_lane_pane_shows_the_cue_for_a_silent_lane(self): + now = [1000.0] + + def clock(): + return now[0] + + screen = FakeScreen(width=80, height=24) + view = taskview.LanesView( + screen, "Setup", + [taskview.TaskLane("Build", [_step("one")])], clock=clock) + lane = view._lanes[0] + view._handle_lane_event( + lane, {"kind": "step_start", "index": 0, "title": "one"}) + view._ingest_lane_line(lane, "working") + now[0] = lane.last_line_at + 120 + view.render() + text = " ".join(t for _, _, t, _ in screen.strings) + self.assertIn("(no output 2m)", text) + + if __name__ == "__main__": unittest.main() |
