Skip to content

πŸ§ͺ [Testing] Add tests for detect_capo_and_tuning - #371

Closed
seonghobae wants to merge 6 commits into
developfrom
testing-improvement-detect-capo-9321211116098216221
Closed

πŸ§ͺ [Testing] Add tests for detect_capo_and_tuning#371
seonghobae wants to merge 6 commits into
developfrom
testing-improvement-detect-capo-9321211116098216221

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

🎯 What: Adds missing unit tests for the heuristic function detect_capo_and_tuning within services/analysis-engine/src/bandscope_analysis/chords/capo.py.

πŸ“Š Coverage: Covered scenarios:

  • Empty chords list behavior.
  • Drop D tuning detection.
  • Flat keys indicating a Capo 1 scenario (threshold of 2+).
  • Fallback standard tuning with both sharp/natural non-flat keys.

✨ Result: Test coverage for capo.py and overall codebase improves, contributing to the 100% test coverage metric in the CI pipeline.


PR created automatically by Jules for task 9321211116098216221 started by @seonghobae

@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@opencode-agent

opencode-agent Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: f80f0220c40f71998e61fa25d5419553de8b818e
  • Workflow run: 28159730882
  • Workflow attempt: 1
  • Gate result: APPROVE (approval step)

Pull request overview

No actionable findings or failed checks detected. PR #371 is ready for merge.

Findings

No blocking findings from OpenCode's independent review.

Verification

  • Review source: independent OpenCode review of the current checkout, focused changed hunks, and current-head GitHub Check evidence.
  • Structural exploration: completed before approval; if structural exploration, changed-file inspection, or evidence completeness is missing, OpenCode must not approve.
  • Result: APPROVE
  • Reason: No source-backed blockers found and structural exploration completed.

Gate evidence

  • Head SHA: f80f0220c40f71998e61fa25d5419553de8b818e
  • Workflow run: 28159730882
  • Workflow attempt: 1

Copilot AI review requested due to automatic review settings June 25, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated unit test module for the detect_capo_and_tuning heuristic in the analysis engine.

Changes:

  • Introduces test_capo.py with multiple scenarios for capo/tuning detection outcomes.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6 to +20
def test_detect_capo_empty_chords() -> None:
"""Test with empty list of chords."""
result = detect_capo_and_tuning([])
assert result == {"capo": None, "tuning": "Standard"}


def test_detect_capo_drop_d() -> None:
"""Test Drop D tuning detection."""
result = detect_capo_and_tuning(["D5", "G5", "A5"])
assert result == {"capo": 0, "tuning": "Drop D"}

# Mixed chords including D5
result = detect_capo_and_tuning(["G", "C", "D5", "Em"])
assert result == {"capo": 0, "tuning": "Drop D"}

Comment on lines +22 to +45
def test_detect_capo_flat_keys_capo_1() -> None:
"""Test detection of flat keys suggesting Capo 1."""
# Exactly 2 flat keys
result = detect_capo_and_tuning(["Eb", "Bb", "Cm", "F"])
assert result == {"capo": 1, "tuning": "Standard"}

# More than 2 flat keys
result = detect_capo_and_tuning(["Eb", "Bb", "Fm", "Ab"])
assert result == {"capo": 1, "tuning": "Standard"}


def test_detect_capo_standard_tuning() -> None:
"""Test standard tuning fallback for common non-flat keys."""
# Common open chords
result = detect_capo_and_tuning(["G", "C", "D", "Em"])
assert result == {"capo": 0, "tuning": "Standard"}

# Only one flat key shouldn't trigger capo 1
result = detect_capo_and_tuning(["F", "Bb", "C", "Dm"])
assert result == {"capo": 0, "tuning": "Standard"}

# Sharp keys
result = detect_capo_and_tuning(["A", "D", "E", "F#m"])
assert result == {"capo": 0, "tuning": "Standard"}
seonghobae and others added 4 commits June 25, 2026 02:22
🎯 **What:** Ensure `GH_TOKEN` does not expire when waiting for other GitHub Checks to finish in the `.github/workflows/opencode-review.yml` pipeline by restoring it during retries.

πŸ“Š **Coverage:** Impacts the OpenCode Review pipeline step.

✨ **Result:** CI checks correctly refresh the token instead of failing with a 401 Bad Credentials after 60 mins.
🎯 **What:** Ensure `GH_TOKEN` and `OPENCODE_APP_TOKEN` prefer the non-expiring static `secrets.OPENCODE_APP_TOKEN` instead of the OIDC generated token which expires after 60 minutes and causes HTTP 401 Bad Credentials errors when waiting for long jobs.

πŸ“Š **Coverage:** Impacts the OpenCode Review pipeline step.

✨ **Result:** CI checks correctly refresh the token instead of failing with a 401 Bad Credentials after 60 mins.
… properly assigning JOB_GITHUB_TOKEN

🎯 **What:** Ensure `wait_for_peer_github_checks` correctly uses the non-expiring (job duration) `github.token` without globally polluting the shell's `GH_TOKEN` environment variable.

πŸ“Š **Coverage:** Impacts the OpenCode Review pipeline step.

✨ **Result:** CI checks correctly refresh the token locally to the `gh` api execution context instead of failing with a 401 Bad Credentials after 60 mins and without clobbering the approval review token.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

No actionable findings or failed checks detected. PR #371 is ready for merge.

Findings

No blocking findings from OpenCode's independent review.

Verification

  • Review source: independent OpenCode review of the current checkout, focused changed hunks, and current-head GitHub Check evidence.
  • Structural exploration: completed before approval; if structural exploration, changed-file inspection, or evidence completeness is missing, OpenCode must not approve.
  • Result: APPROVE
  • Reason: No source-backed blockers found and structural exploration completed.

Gate evidence

  • Head SHA: f80f0220c40f71998e61fa25d5419553de8b818e
  • Workflow run: 28159730882
  • Workflow attempt: 1

@seonghobae

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by the current capo/tuning coverage in test_chords.py and test_tuning.py. This older branch is conflicting and no longer provides a clean merge path.

@seonghobae seonghobae closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants