What changed, and why it matters
This commit only adds a new unit test to the project's test suite. It verifies that a version-reporting override method works correctly and that the override is blocked when running on the actual SeedSigner OS. There are no changes to production code, no bug fixes, and no security-related behavior changes.
No action needed; this is a routine test-coverage addition.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single test method, test_override_data, to tests/test_version.py. It exercises Version.override_data() under two conditions: (1) while mocking Settings.HOSTNAME as Settings.SEEDSIGNER_OS, it asserts that calling override_data raises NotAllowedInSeedSignerOS; (2) outside that mocked environment, it asserts that override_data correctly overrides version name, fork, commit hash, and timestamp. No application code is modified.
Changed components
tests/test_version.pyInspect captured patch +38 / −0
diff --git a/tests/test_version.py b/tests/test_version.py
index e2bc149..e37014c 100644
--- a/tests/test_version.py
+++ b/tests/test_version.py
@@ -804,6 +804,44 @@ class TestVersion(VersionBaseTest):
Version.get_version_timestamp() == TEST__VERSION_TIMESTAMP
+
+ def test_override_data(self, mock_popen: Mock):
+ """
+ Test that we can override the version data via the Version.override_version_data()
+ method.
+ """
+ override_name = "v9.9.9-test"
+ override_fork = "TestFork"
+ override_commit_hash = "abcd123"
+ override_timestamp = datetime(2030, 1, 1, 0, 0, 0)
+
+ # Initially the version data is pulled from the usual sources
+ self.write_test_version_file()
+ with patch("seedsigner.models.settings.Settings.HOSTNAME", Settings.SEEDSIGNER_OS):
+ assert Version.get_version_name() == f"v{TEST__VERSION_DICT[VersionUtils.VERSIONFILE_ATTR__NAME]}"
+ assert Version.get_version_fork() == TEST__VERSION_DICT[VersionUtils.VERSIONFILE_ATTR__FORK]
+ assert Version.get_version_commit_hash() == TEST__VERSION_DICT[VersionUtils.VERSIONFILE_ATTR__COMMIT_HASH]
+ assert Version.get_version_timestamp() == TEST__VERSION_TIMESTAMP
+
+ # While we're in the mocked SeedSigner OS environment, verify that the
+ # override is not allowed.
+ with pytest.raises(NotAllowedInSeedSignerOS):
+ Version.override_data()
+
+ # No longer in the mocked SeedSigner OS environment; should be allowed now.
+ Version.override_data(
+ version_name=override_name,
+ version_fork=override_fork,
+ version_commit_hash=override_commit_hash,
+ version_timestamp=override_timestamp,
+ )
+
+ assert Version.get_version_name() == override_name
+ assert Version.get_version_fork() == override_fork
+ assert Version.get_version_commit_hash() == override_commit_hash
+ assert Version.get_version_timestamp() == override_timestamp
+
+
def test_get_last_edit(self):
"""
Test that get_last_src_edit returns a sane datetime object. Assumes the system
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.