Skip to content

Commit

Permalink
Fix arguments to use the 'append' mode [CLOUDDST-501]
Browse files Browse the repository at this point in the history
Using the append mode allows pub to pass multiple arch, bundle, or
operator arguments. A new testcase was added for adding multiple
bundles.
  • Loading branch information
querti committed May 22, 2020
1 parent 4dd4b9d commit 8818594
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"help": "architecture to rebuild",
"required": False,
"type": str,
"count": "+",
"action": "append",
},
("--overwrite-from-index",): {
"group": "IIB service",
Expand All @@ -119,7 +119,7 @@
"help": "<hostname>/<namespace>/<image>:<tag> of bundle",
"required": True,
"type": str,
"count": "+",
"action": "append",
}
ADD_CMD_ARGS[("--iib-legacy-org",)] = {
"group": "IIB service",
Expand All @@ -134,7 +134,7 @@
"help": "operator name",
"required": True,
"type": str,
"count": "+",
"action": "append",
}


Expand Down
42 changes: 42 additions & 0 deletions tests/test_iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,48 @@ def test_add_bundles_py(
fixture_pulplib_repo_publish.assert_called_once()


def test_add_bundles_py_multiple_bundles(
fixture_iib_client,
fixture_pulp_client,
fixture_iib_krb_auth,
fixture_pulplib_repo_publish,
fixture_pulplib_repo_sync,
fixture_container_image_repo,
fixture_common_iib_op_args,
):

repo = fixture_container_image_repo
fixture_pulp_client.return_value.search_repository.return_value = [repo]
fixture_pulp_client.return_value.get_repository.return_value = repo
with setup_entry_point_py(
("pubtools_iib", "console_scripts", "pubtools-iib-add-bundles"),
{"PULP_PASSWORD": "pulp-password", "CNR_TOKEN": "cnr_token"},
) as entry_func:
retval = entry_func(
["cmd"]
+ fixture_common_iib_op_args
+ ["--bundle", "bundle1", "--bundle", "bundle2"]
)

assert isinstance(retval, IIBBuildDetailsModel)

fixture_iib_client.assert_called_once_with(
"iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False
)
fixture_iib_client.return_value.add_bundles.assert_called_once_with(
"index-image",
"binary-image",
["bundle1", "bundle2"],
["arch"],
cnr_token="cnr_token",
overwrite_from_index=True,
)
fixture_pulplib_repo_sync.assert_called_once()
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com"

fixture_pulplib_repo_publish.assert_called_once()


@pytest.mark.parametrize(
"extra_args,push_items,mock_calls_tester",
[
Expand Down

0 comments on commit 8818594

Please sign in to comment.