def testToRemoveAllStocksAndGroups(self):
     stocks = getAllStocks()
     for stock in stocks:
         removeStock(stock)
     for i in range(0,12):
         stockGroups = getAllStockGroupsByClass(i)
         for stockGroup in stockGroups:
             removeStockGroups(stockGroup)
def addStock(newStock):
    listOfStocks = getAllStocks()
    saveStock(newStock)
    print "Added stock %s" % newStock
    if len(listOfStocks) is not 0:
        combinationsOfStockGroup = getCombination(newStock, listOfStocks)
        print combinationsOfStockGroup
        for stockGroup in combinationsOfStockGroup.values():
            saveStockGroup(stockGroup)
    def testAddStock(self):

        print "Current Stocks: "
        print "%s" % ("\n".join([str(elem) for elem in getAllStocks()]))
        stockList = []
        print "Adding stocks..."
        for i in range(0, 10):
            stock = Stock(str(i), "test" + str(i), (0.2 + 0.01 * i), (0.1 + 0.01 * i))
            stockList.append(stock)
            addStock(stock)
            # addStock()
        storedStocks = getAllStocks()
        for stock in storedStocks:
            print "Stored : %s" % stock

        for i in range(0, 12):
            storedStockGroups = getAllStockGroupsByClass(i)
            for stockGroup in storedStockGroups:
                print stockGroup.getGroupId()
 def testStockAddingAndRemoving(self):
     stock = Stock(str(9),'test9', (0.2+ 0.01), (0.1 + 0.01))
     assert(saveStock(stock) is True)
     stock2 = getStock(stock)
     assert(stock2 is not None and stock2 == stock)
     val = removeStock(stock2)
     assert(val is True)
     stock2 = getStock(stock)
     assert(stock2 is None)
     assert(saveStock(stock) is True)
     stock2 = Stock(str(8),'test8', (0.2+ 0.01), (0.1 + 0.01))
     assert(saveStock(stock2) is True)
     stockList = getAllStocks()
     assert(len(stockList) >=2 )
     val = False
     for stockReturned in stockList:
         val = val or stockReturned.uid in ['9','8']
     assert(val is True)
     for stockReturned in stockList:
         assert(removeStock(stockReturned) is True)