Skip to content

Commit

Permalink
Make bundles an optional parameter in the IIB request [CLOUDDST-2205]
Browse files Browse the repository at this point in the history
If no bundles were specified, the IIB will be called without
'bundles' parameter.
  • Loading branch information
querti committed Sep 10, 2020
1 parent ac44d13 commit 03e7f8f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
4 changes: 3 additions & 1 deletion iiblib/iibclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,12 @@ def add_bundles(
post_data = {
"from_index": index_image,
"binary_image": binary_image,
"bundles": bundles,
"add_arches": arches,
}

if bundles:
post_data["bundles"] = bundles

if cnr_token:
post_data["cnr_token"] = cnr_token

Expand Down
48 changes: 29 additions & 19 deletions tests/test_iib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,34 @@ def test_iib_client(fixture_build_details_json, fixture_builds_page1_json):
assert iibc.add_bundles(
"index-image", "binary", ["bundles-map"], []
) == IIBBuildDetailsModel.from_dict(fixture_build_details_json)
assert iibc.add_bundles(
"index-image",
"binary",
["bundles-map"],
[],
cnr_token="cnr",
organization="org",
overwrite_from_index=True,
overwrite_from_index_token="str",
) == IIBBuildDetailsModel.from_dict(fixture_build_details_json)
assert (
iibc.add_bundles(
"index-image",
"binary",
["bundles-map"],
[],
cnr_token="cnr",
organization="org",
overwrite_from_index=True,
overwrite_from_index_token="str",
)
== IIBBuildDetailsModel.from_dict(fixture_build_details_json)
)
assert (
iibc.add_bundles("index-image", "binary", ["bundles-map"], [], raw=True)
== fixture_build_details_json
)
assert iibc.remove_operators(
"index-image",
"binary",
["operator1"],
[],
overwrite_from_index=True,
overwrite_from_index_token="str",
) == IIBBuildDetailsModel.from_dict(fixture_build_details_json)
assert (
iibc.remove_operators(
"index-image",
"binary",
["operator1"],
[],
overwrite_from_index=True,
overwrite_from_index_token="str",
)
== IIBBuildDetailsModel.from_dict(fixture_build_details_json)
)
assert (
iibc.remove_operators("index-image", "binary", ["operator1"], [], raw=True)
== fixture_build_details_json
Expand Down Expand Up @@ -206,7 +212,11 @@ def test_iib_client_failure(fixture_build_details_json):
iibc = IIBClient("fake-host")
with pytest.raises(ValueError, match=error_msg):
iibc.remove_operators(
"index-image", "binary", ["operator1"], [], overwrite_from_index=True,
"index-image",
"binary",
["operator1"],
[],
overwrite_from_index=True,
)
with pytest.raises(ValueError, match=error_msg):
iibc.remove_operators(
Expand Down

0 comments on commit 03e7f8f

Please sign in to comment.