def test_create_product_version(mock_create_new_product_version, mock_create_product_version_object, mock_version_exists_for_product): result = productversions.create_product_version_raw(1, '1.0') mock_version_exists_for_product.assert_called_once_with(1, '1.0') mock_create_product_version_object.assert_called_once_with(product_id=1, version='1.0') mock_create_new_product_version.assert_called_once_with(body='mock-product-version') assert result == 'SUCCESS'
def test_product_version_operations(new_product, new_config): randversion = testutils.gen_random_version() # create a test ProductVersion version_rest = productversions.create_product_version_raw(product_id=new_product.id, version=randversion) # add_product_version configs_api.add_product_version(id=new_config.id, body=version_rest) # get_product_versions config_versions = configs_api.get_product_versions(id=new_config.id) assert version_rest.id in [x.id for x in config_versions.content] # remove_product_version configs_api.remove_product_version(id=new_config.id, product_version_id=version_rest.id) config_versions = configs_api.get_product_versions(id=new_config.id) if config_versions.content is not None: assert version_rest.id not in [x.id for x in config_versions.content]
def get_product_version(product_name, product_version): products_version = None try: products_versions = products.list_versions_for_product_raw(name=product_name) if products_versions: for product in products_versions: if product.version == product_version: products_version = product.id else: logging.debug('Product does not have any versions') except ValueError: logging.debug('Product version not found') if products_version is None: p = products.get_product_raw(name=product_name) if p is None: logging.error('Product not found') return None pv = productversions.create_product_version_raw(p.id, product_version) products_version = pv.id return products_version
def new_version(new_product): version = productversions.create_product_version_raw( product_id=new_product.id, version=get_unique_version(new_product.id)) return version
def test_create_product_version_exception(mock_get_specific, mock): with pytest.raises(argparse.ArgumentTypeError): productversions.create_product_version_raw(1, '1.0') mock.assert_called_once_with(1, '1.0') mock_get_specific.assert_called_once_with(id=1)
def new_version(new_product): version = productversions.create_product_version_raw( product_id=new_product.id, version=get_unique_version(new_product.id)) return version