Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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:
Expand Down Expand Up @@ -44,3 +45,15 @@ def test_isolated_environment_updates_environ() -> None:
with isolated_environment(environ={"NEW_VAR": "new_value"}):
assert os.environ["NEW_VAR"] == "new_value"
assert "NEW_VAR" not in os.environ

#---------------------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
Comment on lines +51 to +54
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.



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
Comment on lines +57 to +59
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.