示例#1
0
def createProductList():
    productList = []
    productList.append(createProduct('flour_1kg', 5, 10))
    productList.append(createProduct('sugar_1kg', 7, 100))
    productList.append(createProduct('bread', 1, 50))
    productList.append(createProduct('butter_200g', 2, 25))
    productList.append(createProduct('milk_1l', 2, 140))
    return productList
    
示例#2
0
文件: ui.py 项目: adrianPascan/FP
def UI_addProductToList(productList, name, price, quantity):
    try:
        price = validateStrictlyPositiveInteger(price)
        quantity = validateStrictlyPositiveInteger(quantity)
        addProductToList(productList, createProduct(name, price, quantity))
    except ValueError:
        print('Price / Quantity must be strictly positive integers.')
示例#3
0
def test_createProduct ():
    product = createProduct('flour', 5, 10)
    assert product[0] == 'flour'
    assert product[1] == 5
    assert product[2] == 10
示例#4
0
def test_stringProductList():
    productList = []
    assert stringProductList(productList) == 'Product list is void.'
    addProductToList(productList, createProduct('flour', 5, 10))
    assert stringProductList(productList) == 'Product list:\nflour: 5$, 10 items'
示例#5
0
def test_addProductToList ():
    productList = []
    addProductToList(productList, createProduct('flour', 5, 10))
    assert len(productList) == 1 and productList[0][0] == 'flour'