Skip to content

πŸ§ͺ [testing improvement] Add tests for sections utils#423

Closed
seonghobae wants to merge 5 commits into
developfrom
testing/sections-utils-1117475471326488740
Closed

πŸ§ͺ [testing improvement] Add tests for sections utils#423
seonghobae wants to merge 5 commits into
developfrom
testing/sections-utils-1117475471326488740

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

🎯 What: The validate_section function in src/bandscope_analysis/sections/utils.py had no test coverage. This PR adds a missing test file to verify its logic.

πŸ“Š Coverage: The new test suite (tests/test_sections_utils.py) covers:

  • Valid sections containing an "id"
  • Valid sections missing an "id"
  • Invalid section types (e.g., strings) and None, ensuring they return a fallback ID and log a warning correctly.

✨ Result: Test coverage for utils.py has reached 100%, and the overall analysis-engine test suite maintains a 100% test coverage and passes successfully without regressions.


PR created automatically by Jules for task 1117475471326488740 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 22, 2026

Copy link
Copy Markdown

OpenCode Review Overview

  • Head SHA: 1e667f0c4f231b150734a5880076e4e3f2a608bf
  • Workflow run: 28151207851
  • Workflow attempt: 1
  • Gate result: APPROVE (exit 0)

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

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds missing unit tests for validate_section in bandscope_analysis.sections.utils to improve/ensure coverage for valid inputs and invalid section formats.

Changes:

  • Introduce a new test module covering validate_section return values for valid sections (with/without id)
  • Add tests for invalid section inputs (non-dict and None) ensuring fallback IDs and correct warning logging

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

Comment on lines +33 to +60
def test_validate_section_invalid_type() -> None:
"""Test validate_section with an invalid section type (not a dict)."""
logger = MagicMock(spec=logging.Logger)
section = "not a dict"

result = validate_section(section, 2, logger)

assert result == "section-2"
logger.warning.assert_called_once_with(
"Invalid section format at index %d; expected dict, got %s",
2,
"str",
)


def test_validate_section_none_type() -> None:
"""Test validate_section with None."""
logger = MagicMock(spec=logging.Logger)
section = None

result = validate_section(section, 3, logger)

assert result == "section-3"
logger.warning.assert_called_once_with(
"Invalid section format at index %d; expected dict, got %s",
3,
"NoneType",
)

def test_validate_section_valid_with_id() -> None:
"""Test validate_section with a valid section containing an 'id'."""
logger = MagicMock(spec=logging.Logger)

def test_validate_section_valid_without_id() -> None:
"""Test validate_section with a valid dict but missing an 'id'."""
logger = MagicMock(spec=logging.Logger)

def test_validate_section_invalid_type() -> None:
"""Test validate_section with an invalid section type (not a dict)."""
logger = MagicMock(spec=logging.Logger)

def test_validate_section_none_type() -> None:
"""Test validate_section with None."""
logger = MagicMock(spec=logging.Logger)
@seonghobae

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #429. #429 carries the validate_section coverage as a small focused test file with the parametrization and stricter warning assertions already addressed; this branch is conflicting and includes broad unrelated workflow/CI changes.

@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