mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
roledb: Make get_dirty_roles() return sorted list
roledb.get_dirty_roles(repo_name) returns the list representation of the global _dirty_roles[repo_name] set. To make the return value deterministic this commit sorts the list before returning it. The commit also removes calls to sorted on the return value of get_dirty_roles in test_roledb.py and test_repository_tool.py. Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This commit is contained in:
parent
e7d3dd4181
commit
647f712f06
3 changed files with 6 additions and 6 deletions
|
|
@ -357,7 +357,7 @@ def test_writeall(self):
|
|||
self.assertEqual([], tuf.roledb.get_dirty_roles(repository_name))
|
||||
|
||||
repository.mark_dirty(['root', 'timestamp'])
|
||||
self.assertEqual(['root', 'timestamp'], sorted(tuf.roledb.get_dirty_roles(repository_name)))
|
||||
self.assertEqual(['root', 'timestamp'], tuf.roledb.get_dirty_roles(repository_name))
|
||||
repository.unmark_dirty(['root'])
|
||||
self.assertEqual(['timestamp'], tuf.roledb.get_dirty_roles(repository_name))
|
||||
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ def test_mark_dirty(self):
|
|||
self.assertEqual([rolename], tuf.roledb.get_dirty_roles())
|
||||
|
||||
tuf.roledb.mark_dirty(['dirty_role'])
|
||||
self.assertEqual([rolename2, rolename], sorted(tuf.roledb.get_dirty_roles()))
|
||||
self.assertEqual([rolename2, rolename], tuf.roledb.get_dirty_roles())
|
||||
|
||||
# Verify that a role cannot be marked as dirty for a non-existent
|
||||
# repository.
|
||||
|
|
@ -735,9 +735,9 @@ def test_unmark_dirty(self):
|
|||
tuf.roledb.update_roleinfo(rolename2, roleinfo2, mark_role_as_dirty)
|
||||
|
||||
tuf.roledb.unmark_dirty(['dirty_role'])
|
||||
self.assertEqual([rolename], sorted(tuf.roledb.get_dirty_roles()))
|
||||
self.assertEqual([rolename], tuf.roledb.get_dirty_roles())
|
||||
tuf.roledb.unmark_dirty(['targets'])
|
||||
self.assertEqual([], sorted(tuf.roledb.get_dirty_roles()))
|
||||
self.assertEqual([], tuf.roledb.get_dirty_roles())
|
||||
|
||||
# What happens for a role that isn't dirty? unmark_dirty() should just
|
||||
# log a message.
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ def get_dirty_roles(repository_name='default'):
|
|||
None.
|
||||
|
||||
<Returns>
|
||||
A list of the roles that have been modified.
|
||||
A sorted list of the roles that have been modified.
|
||||
"""
|
||||
|
||||
# Does 'repository_name' have the correct format? Raise
|
||||
|
|
@ -444,7 +444,7 @@ def get_dirty_roles(repository_name='default'):
|
|||
raise securesystemslib.exceptions.InvalidNameError('Repository name does'
|
||||
' not' ' exist: ' + repository_name)
|
||||
|
||||
return list(_dirty_roles[repository_name])
|
||||
return sorted(list(_dirty_roles[repository_name]))
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue