Files
github-spec-kit/tests/test_version_imports.py
darion-yaphet d947fda96f refactor: extract _version.py from __init__.py (PR-3/8) (#2550)
* refactor: extract _version.py from __init__.py (PR-3/8)

Move version-checking helpers and `specify self` sub-commands into a
focused `_version.py` module.

Moved symbols:
- GITHUB_API_LATEST — GitHub releases API endpoint constant
- _get_installed_version — importlib.metadata-based version lookup
- _normalize_tag — strip leading 'v' from release tag strings
- _is_newer — PEP 440 version comparison
- _fetch_latest_release_tag — single outbound call to GitHub API
- self_app — Typer sub-app for `specify self`
- self_check, self_upgrade — `specify self check/upgrade` commands

Dependency rule: _version.py imports only stdlib + packaging + ._console.

Backward compatibility: GITHUB_API_LATEST, self_check, self_upgrade
remain importable from specify_cli via re-exports in __init__.py.

Update test_upgrade.py to import helpers from specify_cli._version and
patch at the correct module path (specify_cli._version.*).
Add test_version_imports.py as regression guard.

* fix(tests): update _fetch_latest_release_tag import path in test_authentication.py

PR-3 moved _fetch_latest_release_tag from specify_cli into
specify_cli._version. test_upgrade.py was updated at the time, but
test_authentication.py::TestFetchLatestReleaseTagDelegation still
imported from the old location, causing ImportError on all three
delegation tests. Update all three inline imports to the correct
module path.
2026-05-15 13:12:24 -05:00

42 lines
1.1 KiB
Python

"""Regression guard: version symbols must remain importable from specify_cli."""
from specify_cli import (
GITHUB_API_LATEST,
self_check,
self_upgrade,
)
def test_version_symbols_importable():
assert isinstance(GITHUB_API_LATEST, str)
assert GITHUB_API_LATEST.startswith("https://")
assert callable(self_check)
assert callable(self_upgrade)
def test_version_symbols_available_from_star_import():
namespace = {}
exec("from specify_cli import *", namespace)
for symbol in ("GITHUB_API_LATEST", "self_check", "self_upgrade"):
assert symbol in namespace
def test_version_module_symbols_directly_importable():
from specify_cli._version import (
GITHUB_API_LATEST,
_fetch_latest_release_tag,
_get_installed_version,
_is_newer,
_normalize_tag,
self_app,
self_check,
self_upgrade,
)
assert callable(_get_installed_version)
assert callable(_normalize_tag)
assert callable(_is_newer)
assert callable(_fetch_latest_release_tag)
assert callable(self_check)
assert callable(self_upgrade)
assert self_app is not None