Skip to content

Commit d1dfa9a

Browse files
Copilotmrjf
andauthored
Address code review: fix imports and use exact step name matching in tests
Agent-Logs-Url: https://github.com/githubnext/autoloop/sessions/3013e45a-953d-4f06-bdab-ed720379b412 Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent 8526222 commit d1dfa9a

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

tests/test_scheduling.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -694,17 +694,17 @@ class TestWorkflowStepOrdering:
694694
causing incorrect selection/skip behaviour.
695695
"""
696696

697+
CLONE_STEP = "Clone repo-memory for scheduling"
698+
SCHED_STEP = "Check which programs are due"
699+
697700
def _load_steps(self):
698701
"""Return the list of pre-step names from workflows/autoloop.md."""
699-
import os, re, yaml
702+
import os
703+
import re
704+
700705
wf_path = os.path.join(os.path.dirname(__file__), "..", "workflows", "autoloop.md")
701706
with open(wf_path) as f:
702707
content = f.read()
703-
# The YAML frontmatter (before `---` + markdown body) contains the steps.
704-
# Extract the frontmatter block (first --- ... --- block including 'steps:').
705-
# The source file has the structure: ---\n<yaml>\n---\nsteps:\n - ...\n\nsource: ...
706-
# We need everything from start to the line "source: ..." or "engine: ..."
707-
# Actually, the whole pre-body section is YAML-ish; let's just find step names.
708708
step_names = []
709709
for m in re.finditer(r'^\s*-\s*name:\s*(.+)$', content, re.MULTILINE):
710710
step_names.append(m.group(1).strip())
@@ -713,28 +713,16 @@ def _load_steps(self):
713713
def test_clone_step_exists(self):
714714
"""A step that clones repo-memory for scheduling must exist."""
715715
steps = self._load_steps()
716-
clone_steps = [s for s in steps if "repo-memory" in s.lower() and "schedul" in s.lower()]
717-
assert len(clone_steps) >= 1, (
718-
"Expected a repo-memory clone step for scheduling, found none. "
719-
f"Steps: {steps}"
716+
assert self.CLONE_STEP in steps, (
717+
f"Expected step '{self.CLONE_STEP}' not found. Steps: {steps}"
720718
)
721719

722720
def test_clone_before_scheduling(self):
723721
"""The repo-memory clone step must come before 'Check which programs are due'."""
724722
steps = self._load_steps()
725-
clone_idx = None
726-
sched_idx = None
727-
for i, name in enumerate(steps):
728-
if "repo-memory" in name.lower() and "schedul" in name.lower():
729-
clone_idx = i
730-
break
731-
for i, name in enumerate(steps):
732-
if name == "Check which programs are due":
733-
sched_idx = i
734-
break
735-
assert clone_idx is not None, f"Clone step not found. Steps: {steps}"
736-
assert sched_idx is not None, f"Scheduling step not found. Steps: {steps}"
723+
clone_idx = steps.index(self.CLONE_STEP)
724+
sched_idx = steps.index(self.SCHED_STEP)
737725
assert clone_idx < sched_idx, (
738-
f"Clone step (index {clone_idx}) must come before scheduling step "
739-
f"(index {sched_idx}). Steps: {steps}"
726+
f"'{self.CLONE_STEP}' (index {clone_idx}) must come before "
727+
f"'{self.SCHED_STEP}' (index {sched_idx}). Steps: {steps}"
740728
)

0 commit comments

Comments
 (0)