Skip to content

Commit

Permalink
_mock_package_build
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Dec 27, 2024
1 parent c2a341d commit cf019c0
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lambdas/pkgpush/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,11 @@ def make_request(self, params, **kwargs):
)

@contextlib.contextmanager
def _mock_package_build(self, entries, *, message=..., expected_workflow=...):
def _mock_package_build(self, entries, *, message=..., expected_workflow=..., put_options=None):
if message is ...:
message = self.dst_commit_message
if put_options is None:
put_options = {}

# Use a test package to verify manifest entries
test_pkg = Package()
Expand All @@ -614,11 +616,6 @@ def _mock_package_build(self, entries, *, message=..., expected_workflow=...):
self.s3_stubber.add_response(
'put_object',
service_response={},
expected_params={
'Body': manifest.read(),
'Bucket': self.dst_bucket,
'Key': f'.quilt/packages/{test_pkg.top_hash}',
},
)
self.s3_stubber.add_response(
'put_object',
Expand All @@ -627,15 +624,17 @@ def _mock_package_build(self, entries, *, message=..., expected_workflow=...):
'Body': str.encode(test_pkg.top_hash),
'Bucket': self.dst_bucket,
'Key': f'.quilt/named_packages/{self.dst_pkg_name}/{str(int(self.mock_timestamp))}',
**put_options,
},
)
self.s3_stubber.add_response(
'put_object',
"put_object",
service_response={},
expected_params={
'Body': str.encode(test_pkg.top_hash),
'Bucket': self.dst_bucket,
'Key': f'.quilt/named_packages/{self.dst_pkg_name}/latest',
"Body": str.encode(test_pkg.top_hash),
"Bucket": self.dst_bucket,
"Key": f".quilt/named_packages/{self.dst_pkg_name}/latest",
**put_options,
},
)
with mock.patch('quilt3.workflows.validate', return_value=mocked_workflow_data) as workflow_validate_mock:
Expand Down

0 comments on commit cf019c0

Please sign in to comment.