Beispiel #1
0
    def test_parse_pair_ticker_returns_empty_list_for_empty_response(self):
        result = CexioCrawler.parse_pair_ticker("")
        self.assertIsNone(result[0])
        self.assertIsNone(result[1])

        result = CexioCrawler.parse_pair_ticker(None)
        self.assertIsNone(result[0])
        self.assertIsNone(result[1])
Beispiel #2
0
    def test_save_pair_ticker_for_not_existing_pair(self):
        ticker = CexioCrawler.parse_pair_ticker(self.ticker_response)

        exchange_pair = ExchangePair()
        result = CexioCrawler.save_pair_ticker(exchange_pair, ticker[0], ticker[1])

        self.assertFalse(result)
Beispiel #3
0
    def test_parse_pair_ticker_returns_parsed_data_for_mocked_response(self):
        response = self.ticker_response

        result = CexioCrawler.parse_pair_ticker(response)
        self.assertTrue(result[0]) # "bid": 17086.43
        self.assertEquals(result[0], 17086.43)

        self.assertTrue(result[1]) # "ask": 17092
        self.assertEquals(result[1], 17092)
Beispiel #4
0
    def test_save_pair_ticker_for_valid_inputs(self):
        ticker = CexioCrawler.parse_pair_ticker(self.ticker_response)
        exchange = self.exchange
        crawler = CexioCrawler(exchange)
        exchange_pair = crawler.exchange.pairs.first()

        result = CexioCrawler.save_pair_ticker(exchange_pair, ticker[0], ticker[1])
        self.assertTrue(result)
        self.assertEqual(exchange_pair.last_bid, self.saved_ticker_bid)
        self.assertEqual(exchange_pair.last_ask, self.saved_ticker_ask)
Beispiel #5
0
    def test_save_pair_ticker_for_invalid_pair(self):
        ticker = CexioCrawler.parse_pair_ticker(self.ticker_response)

        result = CexioCrawler.save_pair_ticker(None, ticker[0], ticker[1])

        self.assertFalse(result)