def identify_product(self, cvd, product_name, product_label, product_id): org_name = self.get_option('org') cvd_api = ContentViewDefinitionAPI() cvd_products = cvd_api.all_products(org_name, cvd["id"]) products = [prod for prod in cvd_products if prod["id"] == product_id \ or prod["name"] == product_name or prod["label"] == product_label] if len(products) > 1: raise ApiDataError(_("More than 1 product found with the name or label provided, "\ "recommend using product id. The product id may be retrieved "\ "using the 'product list' command.")) elif len(products) == 0: raise ApiDataError(_("Could not find product [ %s ] within organization [ %s ] and definition [%s] ") % ((product_name or product_label or product_id), org_name, cvd["name"])) return products[0]
def run(self): uuid = self.get_option('uuid') task = self.api.status(uuid) if task is None: raise ApiDataError(_("Could not find task [ %s ].") % uuid) self.printer.add_column('uuid', _("UUID")) self.printer.add_column('state', _("State")) self.printer.add_column('progress', _("Progress")) self.printer.add_column('start_time', _("Start Time")) self.printer.add_column('finish_time', ("Finish Time")) self.printer.set_header(_("Task Status")) self.printer.print_item(task) return os.EX_OK
def test_returns_with_error_when_no_repo_found(self): self.mock_options(self.OPTIONS_WITH_NAME) self.mock(self.module, 'get_repo').side_effect = ApiDataError() self.run_action(os.EX_DATAERR)
def test_it_returns_with_error_when_no_product_found(self): self.mock(self.module, 'get_product').side_effect = ApiDataError() self.run_action(os.EX_DATAERR)
def test_it_returns_with_error_if_repo_was_not_found(self): self.mock(self.module, 'get_repo').side_effect = ApiDataError() self.run_action(os.EX_DATAERR)
def test_returns_with_error_when_no_provider_found(self): katello.client.core.provider.get_provider.side_effect = ApiDataError() self.assertRaises(ApiDataError, self.sync_action.sync_provider, [self.PROVIDER, self.ORGANIZATION], {})
def test_it_returns_with_error_if_product_was_not_found(self): self.mock(self.action, 'identify_product').side_effect = ApiDataError() self.run_action(os.EX_DATAERR)