Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/program-tending.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- name: Test program-tending contracts
run: |
test -f scripts/tests/test_program_tending.py
python3 -m unittest discover -s scripts/tests -p 'test_program_tending.py' -v
- name: Run program-tending scaffold (slice 1 stubs)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
35 changes: 23 additions & 12 deletions scripts/tests/test_program_tending.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

class ProgramTendingScaffoldTest(unittest.TestCase):
def test_run_log_covers_all_five_sections(self):
log = pt.run(["developing-today/code"])
with mock.patch.object(pt, "_gh_api", return_value=[]):
log = pt.run(["developing-today/code"])
self.assertEqual(
[s["section"] for s in log["sections"]],
["epics", "roadmaps", "projects", "stalled-prs", "loose-ends"],
Expand All @@ -35,7 +36,8 @@ def test_scaffold_is_read_only(self):
self.assertTrue(all(s["status"] == "no-action" for s in log["sections"]))

def test_hard_stops_named_in_log(self):
log = pt.run(["developing-today/code"])
with mock.patch.object(pt, "_gh_api", return_value=[]):
log = pt.run(["developing-today/code"])
for stop in ("held", "user/owned", "do-not-merge", "do-not-auto-edit"):
self.assertIn(stop, log["hard_stops"])

Expand All @@ -47,8 +49,10 @@ def test_fetch_failure_reports_never_fails(self):

def test_cli_run_prints_valid_log(self):
buf = io.StringIO()
with redirect_stdout(buf):
self.assertEqual(pt.main(["--run", "--repo", "developing-today/code"]), 0)
with mock.patch.object(pt, "_gh_api", return_value=[]), redirect_stdout(buf):
self.assertEqual(
pt.main(["--run", "--repo", "developing-today/code"]), 0
)
log = json.loads(buf.getvalue())
self.assertEqual(log["job"], "program-tending")
self.assertEqual(len(log["sections"]), 5)
Expand All @@ -67,15 +71,22 @@ def test_workflow_file_exists_and_is_scheduled(self):
self.assertIn("scripts/program_tending.py", text)

def test_script_runs_isolated(self):
proc = subprocess.run(
bootstrap = "\n".join(
[
sys.executable,
"-I",
str(SCRIPT_DIR / "program_tending.py"),
"--run",
"--repo",
"developing-today/code",
],
"import runpy",
"import sys",
"from unittest import mock",
"response = mock.MagicMock()",
"response.__enter__.return_value = response",
"response.read.return_value = b'[]'",
"response.headers.get.return_value = ''",
"sys.argv = ['program_tending.py', '--run', '--repo', 'developing-today/code']",
"with mock.patch('urllib.request.urlopen', return_value=response):",
f" runpy.run_path({str(SCRIPT_DIR / 'program_tending.py')!r}, run_name='__main__')",
]
)
proc = subprocess.run(
[sys.executable, "-I", "-c", bootstrap],
capture_output=True,
text=True,
timeout=120,
Expand Down