Skip to content

Commit

Permalink
test: Misc update in test_tutorial
Browse files Browse the repository at this point in the history
- Add missing remove_target call from "Delegate to Hashed Bins"
  section
- Add comments to dirty_roles output assertion

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
  • Loading branch information
lukpueh committed Dec 16, 2019
1 parent cb8a4c4 commit fc74cf2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/test_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def test_tutorial(self):
repository.root.load_signing_key(private_root_key)
repository.root.load_signing_key(private_root_key2)

# Patch logger to assert that it accurately logs dirty roles
# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand Down Expand Up @@ -186,6 +187,8 @@ def test_tutorial(self):

repository.timestamp.expiration = datetime.datetime(2080, 10, 28, 12, 8)

# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand Down Expand Up @@ -265,7 +268,8 @@ def test_tutorial(self):
'timestamp_key', 'password')
repository.timestamp.load_signing_key(private_timestamp_key)

# Patch logger to assert that it accurately logs dirty roles
# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand All @@ -278,6 +282,8 @@ def test_tutorial(self):
self.assertTrue(os.path.exists(os.path.join(
'repository','targets', 'myproject', 'file4.txt')))

# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand Down Expand Up @@ -318,7 +324,8 @@ def test_tutorial(self):
'unclaimed_key', 'password')
repository.targets("unclaimed").load_signing_key(private_unclaimed_key)


# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand All @@ -337,6 +344,7 @@ def test_tutorial(self):


# ----- Tutorial Section: Delegate to Hashed Bins
repository.targets('unclaimed').remove_target("myproject/file4.txt")

targets = repository.get_filepaths_in_directory(
os.path.join('repository', 'targets', 'myproject'), recursive_walk=True)
Expand All @@ -362,10 +370,11 @@ def test_tutorial(self):
])



for delegation in repository.targets('unclaimed').delegations:
delegation.load_signing_key(private_unclaimed_key)

# NOTE: The tutorial does not call dirty_roles anymore due to #964 and
# #958. We still call it here to see if roles are dirty as expected.
with mock.patch("tuf.repository_tool.logger") as mock_logger:
repository.dirty_roles()
# Concat strings to avoid Python2/3 unicode prefix problems ('' vs. u'')
Expand Down

0 comments on commit fc74cf2

Please sign in to comment.