Пример #1
0
 def test_addTrade(self):
   nj = self.makeTradeJsons(trades_json)
   db = DB('test.db')
   db.dropTables()
   for j in nj.values():
     if not (db.addTrade(json.dumps(j))):
       self.fail()
Пример #2
0
 def test_addSameClient(self):
   tst_db = DB('test.db')
   tst_db.dropTables()
   if not (tst_db.addClient(client_json)):
     self.fail()
   if tst_db.addClient(client_json):
     self.fail()
Пример #3
0
 def test_addPortfolio(self):
   nj = self.makeTradeJsons(trades_json)
   db = DB('test.db')
   db.dropTables()
   pf_j = self.fillPortfolioVars(db, nj)
   if not (db.addPortfolio(pf_j)):
     self.fail()
   if (db.addPortfolio(pf_j)):
     self.fail()
Пример #4
0
 def fillPortfolioVars(db, nj):
   for j in nj.values():
     db.addTrade(json.dumps(j))
   trades = '['
   for key, value in nj.iteritems():
     tr = value
     DB.setTradeId(tr)
     trades += ('' if key == 1 else ', ') + str(tr['tradeId'])
   trades += ']'
   pf_j = '{"email": "*****@*****.**", "portfolioName": "My portfolio", "trades": %s }' % trades
   return pf_j
Пример #5
0
  def test_getTrades(self):
    nj = TestDB.makeTradeJsons()
    db = DB('test.db')
    db.dropTables()
    db.addClient(test_DB.client_json)
    pf_j = TestDB.fillPortfolioVars(db, nj)
    self.failIf(not (db.addPortfolio(pf_j)))

    cp = ClientPortfolios(db,'*****@*****.**')
    a = [p['portfolioName'] for p in cp.getPortfolios()]
    self.failIf( len(a) <= 0)
    self.failIf(len([t['tradeId'] for t in cp.getTrades('My portfolio')]) <= 0)
Пример #6
0
 def test_getTradeTbl(self):
   tst_db = DB('test.db')
   tst_db.dropTables()
   if not (tst_db.addTrade(trades_json)):
     self.fail()