Skip to content

Commit

Permalink
Metadata API: Remove Signed.bump_version() method
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lukpueh committed Dec 21, 2021
1 parent cc2326d commit a0972b6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
3 changes: 0 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ def test_metadata_base(self) -> None:
snapshot_path = os.path.join(self.repo_dir, "metadata", "snapshot.json")
md = Metadata.from_file(snapshot_path)

self.assertEqual(md.signed.version, 1)
md.signed.bump_version()
self.assertEqual(md.signed.version, 2)
self.assertEqual(md.signed.expires, datetime(2030, 1, 1, 0, 0))
md.signed.bump_expiration()
self.assertEqual(md.signed.expires, datetime(2030, 1, 2, 0, 0))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_updater_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _modify_repository_root(
root = Metadata.from_file(role_path)
modification_func(root)
if bump_version:
root.signed.bump_version()
root.signed.version += 1
root_key_path = os.path.join(self.keystore_directory, "root_key")
root_key_dict = import_rsa_privatekey_from_file(
root_key_path, password="password"
Expand Down
4 changes: 0 additions & 4 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,6 @@ def bump_expiration(self, delta: timedelta = timedelta(days=1)) -> None:
"""Increments the expires attribute by the passed timedelta."""
self.expires += delta

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


class Key:
"""A container class representing the public portion of a Key.
Expand Down

0 comments on commit a0972b6

Please sign in to comment.