Пример #1
0
    def test_parse_pair_orderbook_returns_empty_lists_for_empty_response(self):

        result = CexioCrawler.parse_pair_orderbook("")
        self.assertEquals(type(result[0]), list)
        self.assertFalse(result[0])
        self.assertEquals(type(result[1]), list)
        self.assertFalse(result[1])

        result = CexioCrawler.parse_pair_orderbook(None)
        self.assertEquals(type(result[0]), list)
        self.assertFalse(result[0])
        self.assertEquals(type(result[1]), list)
        self.assertFalse(result[1])
Пример #2
0
    def test_save_pair_orderbook_for_not_existing_pair(self):
        orderbook = CexioCrawler.parse_pair_orderbook(self.orderbook_response)

        exchange_pair = ExchangePair()
        result = CexioCrawler.save_pair_orderbook(exchange_pair, orderbook[0], orderbook[1])

        self.assertFalse(result)
Пример #3
0
    def test_save_pair_orderbook_for_valid_inputs(self):
        orderbook = CexioCrawler.parse_pair_orderbook(self.orderbook_response)
        exchange = self.exchange
        crawler = CexioCrawler(exchange)
        exchange_pair = crawler.exchange.pairs.first()

        result = CexioCrawler.save_pair_orderbook(exchange_pair, orderbook[0], orderbook[1])
        self.assertTrue(result)
        self.assertEqual(exchange_pair.bids, self.saved_orderbook_bids)
        self.assertEqual(exchange_pair.asks, self.saved_orderbook_asks)
Пример #4
0
    def test_parse_pair_orderbook_returns_parsed_data_for_mocked_response(self):
        response = self.orderbook_response

        result = CexioCrawler.parse_pair_orderbook(response)
        self.assertTrue(result[0]) # [250.00, 0.02000000]
        self.assertEquals(len(result[0]), 1)
        self.assertEquals(result[0][0][0], 250.0)
        self.assertEquals(result[0][0][1], 0.02)

        self.assertTrue(result[1]) # [280.00, 20.51246433]
        self.assertEquals(len(result[1]), 1)
        self.assertEquals(result[1][0][0], 280.00)
        self.assertEquals(result[1][0][1], 20.51246433)
Пример #5
0
    def test_save_pair_orderbook_for_invalid_pair(self):
        orderbook = CexioCrawler.parse_pair_orderbook(self.orderbook_response)

        result = CexioCrawler.save_pair_orderbook(None, orderbook[0], orderbook[1])

        self.assertFalse(result)