def test_create_product_attribute():
    global product_attribute_id, valid_product_attribute
    result = ProductAttributes.create_one(valid_product_attribute)
    assert result['success'] is True
    product_attribute_id = result['value']['_id']
    assert ObjectId(product_attribute_id)
    assert result['value']['name'] == valid_product_attribute["name"]
示例#2
0
def update_product_attribute(
    *,
    product_attribute_id: str = Path(
        ..., title="The product_attribute ID as a valid ObjectId"),
    ProductAttribute: ProductAttributeToUpdate,
    CurrentUser: UserOut = Depends(get_current_user)):
    # Exclude sellerId because it seems there is no reason to update it
    return format_result(
        ProductAttributes.update_one(product_attribute_id, ProductAttribute,
                                     {'sellerId'}))
示例#3
0
def delete_product_attribute(product_attribute_id: str,
                             CurrentUser: UserOut = Depends(get_current_user)):
    return format_result(ProductAttributes.delete_one(product_attribute_id))
示例#4
0
def create_product_attribute(ProductAttribute: ProductAttributeToInsert,
                             CurrentUser: UserOut = Depends(get_current_user)):
    if not (hasattr(CurrentUser, 'sellerId')) or CurrentUser.sellerId is None:
        raise mpapi_exceptions({'error': 'USER-HAS-NO-SELLERID'})
    ProductAttribute.sellerId = CurrentUser.sellerId
    return format_result(ProductAttributes.create_one(ProductAttribute))
示例#5
0
def get_product_attribute_by_id(product_attribute_id: str = Path(
    ..., title="The product attribute ID as a valid ObjectId")):
    return format_result(ProductAttributes.get_one(product_attribute_id))
示例#6
0
async def get_product_attributes(skip: int = 0, limit: int = 100):
    return format_result(ProductAttributes.get_many(skip, limit))
def test_delete_product_attribute():
    global product_attribute_id
    result = ProductAttributes.delete_one(product_attribute_id)
    assert result['success'] is True
    result = ProductAttributes.get_one(product_attribute_id)
    assert result['success'] is False
def test_update_product_attribute():
    global product_attribute_id
    name = "Test Update"
    result = ProductAttributes.update_one(product_attribute_id, {"name": name})
    assert result['success'] is True
    assert result['value']['name'] == name