def test_remove_operators_cli( 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, fixture_pushcollector, extra_args, push_items, mock_calls_tester, ): 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 fixture_iib_client.return_value.remove_operators.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict( fake_tm.setup_task(*args, **dict(list(kwargs.items()) + [("op_type", "rm")])) ) with setup_entry_point_cli( ("pubtools_iib", "console_scripts", "pubtools-iib-remove-operators"), "pubtools-iib-remove-operators", fixture_common_iib_op_args + ["--operator", "1"] + extra_args, {"PULP_PASSWORD": "******"}, ) as entry_func: entry_func() assert fixture_pushcollector.items == push_items mock_calls_tester( fixture_iib_client, fixture_pulplib_repo_sync, fixture_pulplib_repo_publish, fixture_iib_krb_auth, )
def test_add_bundles_cli( 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, fixture_pushcollector, extra_args, push_items, mock_calls_tester, ): 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_cli( ("pubtools_iib", "console_scripts", "pubtools-iib-add-bundles"), "pubtools-iib-add-bundle", fixture_common_iib_op_args + ["--bundle", "bundle1", "--iib-legacy-org", "legacy-org"] + extra_args, {"PULP_PASSWORD": "******", "CNR_TOKEN": "cnr_token"}, ) as entry_func: entry_func() assert fixture_pushcollector.items == push_items mock_calls_tester( fixture_iib_client, fixture_pulplib_repo_sync, fixture_pulplib_repo_publish, fixture_iib_krb_auth, )
def test_add_bundles_cli_error( 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, fixture_pushcollector, ): 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 fixture_iib_client.return_value.add_bundles.side_effect = ( lambda *args, **kwargs: IIBBuildDetailsModel.from_dict( fake_tm.setup_task( *args, **dict( list(kwargs.items()) + [("state_seq", ("in_progress", "failed"))])))) with setup_entry_point_cli( ("pubtools_iib", "console_scripts", "pubtools-iib-add-bundles"), "pubtools-iib-add-bundle", fixture_common_iib_op_args + ["--bundle", "bundle1"], { "PULP_PASSWORD": "******", "CNR_TOKEN": "cnr_token", "OVERWRITE_FROM_INDEX_TOKEN": "overwrite_from_index_token", }, ) as entry_func: try: entry_func() assert False, "Should have raised SystemError" except SystemExit: pass assert fixture_pushcollector.items == [ operator_1_push_item_pending, operator_1_push_item_notpushed, ]
def test_remove_operators_cli_error( 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, fixture_pushcollector, ): 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 fixture_iib_client.return_value.remove_operators.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict( fake_tm.setup_task( *args, **dict( list(kwargs.items()) + [("state_seq", ("in_progress", "failed")), ("op_type", "rm")] ) ) ) with setup_entry_point_cli( ("pubtools_iib", "console_scripts", "pubtools-iib-remove-operators"), "pubtools-iib-remove-operators", fixture_common_iib_op_args + ["--operator", "1"], {"PULP_PASSWORD": "******"}, ) as entry_func: try: entry_func() assert False, "Should have raised SystemError" except SystemExit: pass assert fixture_pushcollector.items == [ operator_1_push_item_delete_pending, operator_1_push_item_delete_notpushed, ]