def test_stockException(self):
     # can define custom exception at a later stage if desired
     inv = StoreInventory()
     inv.addProductsCSV("./csvs/emptyStock.csv")
     sales = SalesProductList()
     sales.addProductsCSV("./csvs/stock-sales_TEST.csv")
     with pytest.raises(Exception):
         inv.addSales(sales)
예제 #2
0
 def test_assertions(self):
     inv=StoreInventory()
     sales=SalesProductList()
     orders=OrdersList()
     with pytest.raises(AssertionError):
         assert inv.addOrders(sales) 
     with pytest.raises(AssertionError):
         assert inv.addSales(orders) 
    def test_assertions(self):
        inv = StoreInventory()
        sales = SalesProductList()
        orders = OrdersList()
        with pytest.raises(AssertionError):
            assert inv.addOrders(sales)
        with pytest.raises(AssertionError):
            assert inv.addSales(orders)

#_________________________________________________________________________
#_________________________________________________________________________

    # total orders for SKU item
        '''total cost of orders for SKU'''
 def test_stockTotalCostandRetail(self):
     inv = StoreInventory()
     # to calculate the accumulative  retail available, set addBehavior to
     # salesAddBehaviour (this behavior may be renamed to
     # accumulativeRetailBehaviour)
     inv.setAddStyle(behavior_accumulate_retail())
     inv.addProductsCSV("./csvs/ifix-stock_2016-01-22.csv")
     assert inv.costAll() == 588989.66
     assert inv.costAll(retail=True) == 3244457
    def test_weightedUnitPrice(self):

        inv = StoreInventory()
        # to calculate the accumulative  retail available, set addBehavior to
        # salesAddBehaviour (this behavior may be renamed to
        # accumulativeRetailBehaviour)
        inv.setAddStyle(behavior_accumulate_retail())
        inv.addProductsCSV("./csvs/trendTest/ifix-stock_trendTest.csv")

        orders = OrdersList()
        orders.addProductsCSV("./csvs/trendTest/stock-purchases_trendTest.csv")

        sales = SalesProductList()
        sales.addProductsCSV("./csvs/trendTest/stock-sales_trendTest.csv")

        inv.addOrders(orders)
        wUnitCost = inv.getWeightedUnitCost("6691")

        # rounding is required at the last moment so errors do not accumulate

        assert round(wUnitCost, 2) == 89.61
        assert round(sales["6691"].count * wUnitCost, 2) == -358.43
        inv.addSales(sales)
        assert round(inv["6691"].count * wUnitCost, 2) == 806.47
예제 #6
0
'''
Created on 24 Jan 2016

@author: Craig
'''
from product import Product
from salesProductList import SalesProductList
from storeInventory import StoreInventory
from ordersList import OrdersList


if __name__ == '__main__':
    inv=StoreInventory()
    inv.addProductsCSV("./csvs/ifix-stock_2016-01-22.csv")
 
 
    sales=SalesProductList()
    sales.addProductsCSV("./csvs/stock-sales_TEST.csv")
    print sales["602"].totalCost
    print sales["602"].retail
    print sales["602"].count
     
    orders=OrdersList()
    orders.addProductsCSV("./csvs/stock-purchases_TESTsmall.csv")
     
 
    inv.addOrders(orders)
    inv.addSales(sales)
#     
    
    #--Stock--