Ejemplo n.º 1
0
 def test_XueqiuDao_Filter(self):
     dao = XueqiuDao('../db.sqlite3', 'xueqiu')
     cond = [('mc', 0, 10000)]
     ret = dao.filter(cond)
     self.assertGreater(len(ret), 1)
     stock = XueqiuStock(*ret[0])
     self.assertGreater(stock.mc, 0)
     self.assertGreater(10000, stock.mc)
Ejemplo n.º 2
0
 def test_XueqiuDao_Filter(self):
     dao = XueqiuDao('../db.sqlite3','xueqiu')
     cond = [('mc',0,10000)]
     ret = dao.filter(cond)
     self.assertGreater(len(ret),1)
     stock = XueqiuStock(*ret[0])
     self.assertGreater(stock.mc,0)
     self.assertGreater(10000,stock.mc)
Ejemplo n.º 3
0
 def test_XueqiuSpider(self):
     spider = XueqiuSpider()
     r = []
     r = spider.results()
     self.assertGreater(len(r), 1000)
     if not isinstance(r[0], XueqiuStock):
         raise Exception('type error: result item is not Stock instance')
     dao = XueqiuDao('db.sqlite3', 'xueqiu')
     dao.update(r)
Ejemplo n.º 4
0
 def test_XueqiuSpider(self):
     spider = XueqiuSpider()
     r = []
     r = spider.results()
     self.assertGreater(len(r),1000)
     if not isinstance(r[0],XueqiuStock):
         raise Exception('type error: result item is not Stock instance')
     dao = XueqiuDao('db.sqlite3','xueqiu')
     dao.update(r)
Ejemplo n.º 5
0
 def test_XueqiuDao_Filter_Multi(self):
     dao = XueqiuDao('../db.sqlite3','xueqiu')
     cond = [('mc',-7000,7000),('fmc',-10000,10000)]
     ret = dao.filter(cond)
     self.assertGreater(len(ret),1)
     for item in ret:
         stock = XueqiuStock(*item)
         self.assertGreater(stock['mc'],-7000)
         self.assertGreater(7000,stock['mc'])
         self.assertGreater(stock['fmc'],-10000)
         self.assertGreater(10000,stock['fmc'])
Ejemplo n.º 6
0
 def test_XueqiuDao_Filter_Multi(self):
     dao = XueqiuDao('../db.sqlite3', 'xueqiu')
     cond = [('mc', -7000, 7000), ('fmc', -10000, 10000)]
     ret = dao.filter(cond)
     self.assertGreater(len(ret), 1)
     for item in ret:
         stock = XueqiuStock(*item)
         self.assertGreater(stock['mc'], -7000)
         self.assertGreater(7000, stock['mc'])
         self.assertGreater(stock['fmc'], -10000)
         self.assertGreater(10000, stock['fmc'])
Ejemplo n.º 7
0
    def create_stock_ctrl(self, stock_type):
        setting = self.setting
        if stock_type == 'wencai':
            dao = WencaiDao(setting['db_path'], stock_type)
            ctrl = StockCtrl(setting, dao, WencaiStock, stock_type)
            return ctrl

        elif stock_type == 'xueqiu':
            dao = XueqiuDao(setting['db_path'], stock_type)
            ctrl = StockCtrl(setting, dao, XueqiuStock, stock_type)
            return ctrl
Ejemplo n.º 8
0
 def test_XueqiuDao_Update(self):
     spider = XueqiuSpider()
     ret = spider.results()
     dao = XueqiuDao('../db.sqlite3','xueqiu')
     dao.update(ret)
     self.assertEqual(len(ret),len(dao.all()))
Ejemplo n.º 9
0
 def test_XueqiuDao_Update(self):
     spider = XueqiuSpider()
     ret = spider.results()
     dao = XueqiuDao('../db.sqlite3', 'xueqiu')
     dao.update(ret)
     self.assertEqual(len(ret), len(dao.all()))