Skip to content

[Maintenance] Add unit tests for scripts/get_pr_status.py and resolve placeholder status #191

Description

@sheepdestroyer

Description

Following the review and merge of PR #171 (which resolved the command injection vulnerabilities and added type safety, timeout, and exit code checking to run_cmd), there are a few remaining tasks to ensure robustness and code cleanliness.

Remaining Tasks

  1. Add Unit Tests for run_cmd in scripts/get_pr_status.py

    • Create a test file tests/test_get_pr_status.py to cover run_cmd behavior.
    • Verify that run_cmd correctly strips whitespace from output.
    • Verify that non-zero exit codes raise subprocess.CalledProcessError.
    • Verify that executing commands that hang triggers a subprocess.TimeoutExpired exception.
  2. Evaluate/Implement get_pr_status.py Logic

    • Currently, scripts/get_pr_status.py only contains the helper run_cmd function but has no other implementation or entrypoint.
    • We need to determine if get_pr_status.py should be expanded with actual PR query logic (e.g. using gh CLI commands to check PR review status, unresolved comments, or check statuses) or if the helper should be moved to a shared utility/removed if obsolete.

Example Code for Unit Tests

import pytest
import subprocess
from scripts.get_pr_status import run_cmd

def test_run_cmd_success():
    output = run_cmd(["echo", "hello"])
    assert output == "hello"

def test_run_cmd_error():
    with pytest.raises(subprocess.CalledProcessError):
        run_cmd(["false"])

def test_run_cmd_timeout():
    with pytest.raises(subprocess.TimeoutExpired):
        run_cmd(["sleep", "31"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityCode quality improvementjulesIssues for JulesmaintenanceMaintenance and tech debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions