Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to push item with no destinations #5

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

10 changes: 10 additions & 0 deletions tests/logs/push/test_push/test_push_item_no_destinations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[ INFO] Loading items from koji:https://fakekoji.com?vmi_build=ami_build
[ INFO] Retrieving the mappings for ami_pushitem from https://starmap-example.com
[ INFO] starmap query returned for ami_pushitem : {"name": "test-build", "version": "7.0", "query_response": {"name": "fake-policy", "workflow": "stratosphere", "clouds": {"aws-na": []}}}
[ INFO] Filtering out archive with no destinations: None
[ INFO] Retrieving the mappings for vhd_pushitem from https://starmap-example.com
[ INFO] starmap query returned for vhd_pushitem : {"name": "test-build", "version": "7.0", "query_response": {"name": "fake-policy", "workflow": "stratosphere", "clouds": {"aws-na": []}}}
[ INFO] Filtering out archive with no destinations: None
[ INFO] Collecting results
[ ERROR] Marketplace VM push failed
# Raised: 30
32 changes: 32 additions & 0 deletions tests/push/test_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,38 @@ def test_push_item_no_mapped_arch(
)


@mock.patch("pubtools._marketplacesvm.tasks.push.MarketplacesVMPush.starmap")
def test_push_item_no_destinations(
mock_starmap: mock.MagicMock,
fake_source: mock.MagicMock,
fake_cloud_instance: mock.MagicMock,
ami_push_item: AmiPushItem,
command_tester: CommandTester,
) -> None:
"""Ensure the push item with no destinations is filtered out."""
qr = QueryResponse.from_json(
{
"name": "fake-policy",
"workflow": "stratosphere",
"mappings": {"aws-na": []},
}
)
mock_starmap.query_image_by_name.return_value = qr

command_tester.test(
lambda: entry_point(MarketplacesVMPush),
[
"test-push",
"--starmap-url",
"https://starmap-example.com",
"--credentials",
"eyJtYXJrZXRwbGFjZV9hY2NvdW50IjogInRlc3QtbmEiLCAiYXV0aCI6eyJmb28iOiJiYXIifQo=",
"--debug",
"koji:https://fakekoji.com?vmi_build=ami_build",
],
)


@mock.patch("pubtools._marketplacesvm.tasks.push.MarketplacesVMPush.cloud_instance")
def test_push_item_fail_upload(
mock_cloud_instance: mock.MagicMock,
Expand Down
Loading