Skip to content

Commit 8620f38

Browse files
committed
Metadata API: Remove Signed.bump_version() method
Remove `bump_version()` method, which is just an alias for "+= 1" on the version attribute. For a slim low-level API it seems okay to just directly access/modify the attribute. The extra level of abstraction of "bumping a version" is more appropriate for a repository library (see #1136). This patch also removes a related unit test and updates another one to directly do `(...).version +=`. Signed-off-by: Lukas Puehringer <[email protected]>
1 parent 2840ff7 commit 8620f38

File tree

3 files changed

+1
-8
lines changed

3 files changed

+1
-8
lines changed

tests/test_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@ def test_metadata_base(self) -> None:
260260
snapshot_path = os.path.join(self.repo_dir, "metadata", "snapshot.json")
261261
md = Metadata.from_file(snapshot_path)
262262

263-
self.assertEqual(md.signed.version, 1)
264-
md.signed.bump_version()
265-
self.assertEqual(md.signed.version, 2)
266263
self.assertEqual(md.signed.expires, datetime(2030, 1, 1, 0, 0))
267264

268265
# Test is_expired with reference_time provided

tests/test_updater_ng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _modify_repository_root(
153153
root = Metadata.from_file(role_path)
154154
modification_func(root)
155155
if bump_version:
156-
root.signed.bump_version()
156+
root.signed.version += 1
157157
root_key_path = os.path.join(self.keystore_directory, "root_key")
158158
root_key_dict = import_rsa_privatekey_from_file(
159159
root_key_path, password="password"

tuf/api/metadata.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,6 @@ def is_expired(self, reference_time: Optional[datetime] = None) -> bool:
513513

514514
return reference_time >= self.expires
515515

516-
def bump_version(self) -> None:
517-
"""Increments the metadata version number by 1."""
518-
self.version += 1
519-
520516

521517
class Key:
522518
"""A container class representing the public portion of a Key.

0 commit comments

Comments
 (0)