def unique_bc_name(name_input): valid_bc_name(name_input) if common.get_id_by_name(pnc_api.build_configs, name_input): raise argparse.ArgumentTypeError( "BuildConfiguration name '{}' is already in use".format( name_input)) return name_input
def unique_product_name(name_input): if common.get_id_by_name(pnc_api.products, name_input): raise argparse.ArgumentTypeError( "a Product with the name {} already exists".format(name_input)) return name_input
def existing_product_name(name_input): if not common.get_id_by_name(pnc_api.products, name_input): raise argparse.ArgumentTypeError( "no Product with the name {} exists".format(name_input)) return name_input
def existing_bc_name(name_input): valid_bc_name(name_input) if not common.get_id_by_name(pnc_api.build_configs, name_input): raise argparse.ArgumentTypeError( "no BuildConfiguration with the name {} exists".format(name_input)) return name_input
def unique_environment_name(nameInput): if common.get_id_by_name(pnc_api.environments, nameInput): raise argparse.ArgumentTypeError( "a BuildEnvironment with name {} already exists".format(nameInput)) return nameInput
def unique_product_name(name_input): if common.get_id_by_name(pnc_api.products, name_input): raise argparse.ArgumentTypeError("a Product with the name {} already exists".format(name_input)) return name_input
def existing_environment_name(name_input): if not common.get_id_by_name(pnc_api.environments, name_input): raise argparse.ArgumentTypeError( "no BuildEnvironment exists with name {}".format(name_input)) return name_input
def existing_bc_name(name_input): valid_bc_name(name_input) if not common.get_id_by_name(pnc_api.build_configs, name_input): raise argparse.ArgumentTypeError("no BuildConfiguration with the name {} exists".format(name_input)) return name_input
def existing_product_name(name_input): if not common.get_id_by_name(pnc_api.products, name_input): raise argparse.ArgumentTypeError("no Product with the name {} exists".format(name_input)) return name_input
def unique_environment_name(nameInput): if common.get_id_by_name(pnc_api.environments, nameInput): raise argparse.ArgumentTypeError("a BuildEnvironment with name {} already exists".format(nameInput)) return nameInput
def unique_bc_name(name_input): valid_bc_name(name_input) if common.get_id_by_name(pnc_api.build_configs, name_input): raise argparse.ArgumentTypeError("BuildConfiguration name '{}' is already in use".format(name_input)) return name_input
def existing_environment_name(name_input): if not common.get_id_by_name(pnc_api.environments, name_input): raise argparse.ArgumentTypeError("no BuildEnvironment exists with name {}".format(name_input)) return name_input
def existing_bc_set_name(name_input): if not common.get_id_by_name(sets_api, name_input): raise argparse.ArgumentTypeError( "no BuildConfigurationSet with the name {} exists".format( name_input)) return name_input
def unique_bc_set_name(name_input): if common.get_id_by_name(sets_api, name_input): raise argparse.ArgumentTypeError( "BuildConfigurationSet name '{}' is already in use".format( name_input)) return name_input
def test_get_id_by_name_notfound(): mock_api = create_autospec(BuildconfigurationsApi) mock_api.get_all.return_value = MagicMock(content=[]) result = common.get_id_by_name(mock_api, 'testerino') assert not result
def test_get_id_by_name(): mock_api = create_autospec(BuildconfigurationsApi) mock_api.get_all.return_value = utils.create_mock_list_with_name_attribute() result = common.get_id_by_name(mock_api, 'testerino') assert result == 1