Skip to content

Add tests for pbs_installer_supported_arch#10686

Open
stavroulagalani wants to merge 1 commit intopython-poetry:mainfrom
stavroulagalani:add-tests-for-pbs-installer-arch
Open

Add tests for pbs_installer_supported_arch#10686
stavroulagalani wants to merge 1 commit intopython-poetry:mainfrom
stavroulagalani:add-tests-for-pbs-installer-arch

Conversation

@stavroulagalani
Copy link

@stavroulagalani stavroulagalani commented Jan 11, 2026

Adds unit tests for pbs_installer_supported_arch to improve coverage of tests/helpers.py.

Resolves: #9161

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Tests:

  • Add tests ensuring pbs_installer_supported_arch returns True for supported architectures and False for unsupported architectures.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 11, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds targeted unit tests for pbs_installer_supported_arch to verify accepted and rejected architectures and slightly extends the test_helpers imports accordingly.

File-Level Changes

Change Details Files
Extend helpers test module to cover pbs_installer_supported_arch behavior for supported and unsupported architectures.
  • Import pbs_installer_supported_arch into the helpers test module
  • Add a test validating that known supported architectures return True
  • Add a test validating that known unsupported architectures return False
tests/test_helpers.py

Assessment against linked issues

Issue Objective Addressed Explanation
#9161 Increase test coverage for tests/helpers.py by adding unit tests for previously untested helper functionality (e.g., pbs_installer_supported_arch).

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The inline banner comment (#---------------------2 new tests-----------------------) is unnecessary noise in the test file and could be removed to keep the style consistent with existing tests.
  • Consider parametrizing the supported/unsupported architecture checks with pytest.mark.parametrize to reduce repetition and make it easier to add more cases in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The inline banner comment (`#---------------------2 new tests-----------------------`) is unnecessary noise in the test file and could be removed to keep the style consistent with existing tests.
- Consider parametrizing the supported/unsupported architecture checks with `pytest.mark.parametrize` to reduce repetition and make it easier to add more cases in the future.

## Individual Comments

### Comment 1
<location> `tests/test_helpers.py:51-54` </location>
<code_context>
+
+#---------------------2 new tests-----------------------
+
+def test_pbs_installer_supported_arch_accepts_supported_archs() -> None:
+    assert pbs_installer_supported_arch("x86_64") is True
+    assert pbs_installer_supported_arch("amd64") is True
+    assert pbs_installer_supported_arch("arm64") is True
+
+
</code_context>

<issue_to_address>
**suggestion (testing):** Add tests for architecture aliases and edge cases (e.g. aarch64, case differences, empty string).

Beyond the main happy-path values, please add tests for alias and edge inputs that this helper should handle, e.g. `"aarch64"`, case variants like `"ARM64"`, and clearly invalid-but-string inputs such as `""` or whitespace-only. That will document and lock in the expected normalization and failure behavior.

Suggested implementation:

```python
from tests.helpers import flatten_dict
from tests.helpers import isolated_environment
from tests.helpers import pbs_installer_supported_arch


def test_flatten_dict() -> None:
    with isolated_environment(environ={"NEW_VAR": "new_value"}):
        assert os.environ["NEW_VAR"] == "new_value"
    assert "NEW_VAR" not in os.environ


def test_pbs_installer_supported_arch_accepts_supported_archs() -> None:
    assert pbs_installer_supported_arch("x86_64") is True
    assert pbs_installer_supported_arch("amd64") is True
    assert pbs_installer_supported_arch("arm64") is True


def test_pbs_installer_supported_arch_accepts_aliases_and_case_variants() -> None:
    # Alias for arm64 should be accepted
    assert pbs_installer_supported_arch("aarch64") is True

    # Case-insensitive handling of supported architectures
    assert pbs_installer_supported_arch("ARM64") is True
    assert pbs_installer_supported_arch("X86_64") is True
    assert pbs_installer_supported_arch("AMD64") is True


def test_pbs_installer_supported_arch_rejects_invalid_strings() -> None:
    # Empty and whitespace-only strings should be rejected
    assert pbs_installer_supported_arch("") is False
    assert pbs_installer_supported_arch(" ") is False
    assert pbs_installer_supported_arch("   ") is False

```

These changes assume:
1. `os` is already imported earlier in `tests/test_helpers.py`, since `test_flatten_dict` uses `os.environ`.
2. `pbs_installer_supported_arch("aarch64")` and case variants like `"ARM64"` are expected to be treated as supported; if the helper currently does not normalize aliases/case that way, you will need to update its implementation in `tests/helpers.py` accordingly.
3. If there are additional expectations for invalid inputs (e.g., non-string types), you may want to extend `test_pbs_installer_supported_arch_rejects_invalid_strings` to cover them.
</issue_to_address>

### Comment 2
<location> `tests/test_helpers.py:57-59` </location>
<code_context>
+    assert pbs_installer_supported_arch("arm64") is True
+
+
+def test_pbs_installer_supported_arch_rejects_unsupported_archs() -> None:
+    assert pbs_installer_supported_arch("sparc") is False
+    assert pbs_installer_supported_arch("mips") is False
</code_context>

<issue_to_address>
**suggestion (testing):** Consider adding negative tests for near-miss architectures (e.g. x86, armv7l) to ensure correct rejection.

Currently the rejection test only uses clearly unsupported architectures like `"sparc"` and `"mips"`. Including realistic “near miss” values such as `"x86"`, `"i386"`, or `"armv7l"` (if they’re meant to be rejected) would better exercise the classification logic and reduce the risk of regressions in real-world scenarios.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +51 to +54
def test_pbs_installer_supported_arch_accepts_supported_archs() -> None:
assert pbs_installer_supported_arch("x86_64") is True
assert pbs_installer_supported_arch("amd64") is True
assert pbs_installer_supported_arch("arm64") is True
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Add tests for architecture aliases and edge cases (e.g. aarch64, case differences, empty string).

Beyond the main happy-path values, please add tests for alias and edge inputs that this helper should handle, e.g. "aarch64", case variants like "ARM64", and clearly invalid-but-string inputs such as "" or whitespace-only. That will document and lock in the expected normalization and failure behavior.

Suggested implementation:

from tests.helpers import flatten_dict
from tests.helpers import isolated_environment
from tests.helpers import pbs_installer_supported_arch


def test_flatten_dict() -> None:
    with isolated_environment(environ={"NEW_VAR": "new_value"}):
        assert os.environ["NEW_VAR"] == "new_value"
    assert "NEW_VAR" not in os.environ


def test_pbs_installer_supported_arch_accepts_supported_archs() -> None:
    assert pbs_installer_supported_arch("x86_64") is True
    assert pbs_installer_supported_arch("amd64") is True
    assert pbs_installer_supported_arch("arm64") is True


def test_pbs_installer_supported_arch_accepts_aliases_and_case_variants() -> None:
    # Alias for arm64 should be accepted
    assert pbs_installer_supported_arch("aarch64") is True

    # Case-insensitive handling of supported architectures
    assert pbs_installer_supported_arch("ARM64") is True
    assert pbs_installer_supported_arch("X86_64") is True
    assert pbs_installer_supported_arch("AMD64") is True


def test_pbs_installer_supported_arch_rejects_invalid_strings() -> None:
    # Empty and whitespace-only strings should be rejected
    assert pbs_installer_supported_arch("") is False
    assert pbs_installer_supported_arch(" ") is False
    assert pbs_installer_supported_arch("   ") is False

These changes assume:

  1. os is already imported earlier in tests/test_helpers.py, since test_flatten_dict uses os.environ.
  2. pbs_installer_supported_arch("aarch64") and case variants like "ARM64" are expected to be treated as supported; if the helper currently does not normalize aliases/case that way, you will need to update its implementation in tests/helpers.py accordingly.
  3. If there are additional expectations for invalid inputs (e.g., non-string types), you may want to extend test_pbs_installer_supported_arch_rejects_invalid_strings to cover them.

Comment on lines +57 to +59
def test_pbs_installer_supported_arch_rejects_unsupported_archs() -> None:
assert pbs_installer_supported_arch("sparc") is False
assert pbs_installer_supported_arch("mips") is False
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Consider adding negative tests for near-miss architectures (e.g. x86, armv7l) to ensure correct rejection.

Currently the rejection test only uses clearly unsupported architectures like "sparc" and "mips". Including realistic “near miss” values such as "x86", "i386", or "armv7l" (if they’re meant to be rejected) would better exercise the classification logic and reduce the risk of regressions in real-world scenarios.

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.

Add test coverage for tests/helpers.py

1 participant