Beispiel #1
0
    def test_privat_btc(self):
        xrate = models.XRate.get(from_currency=1000, to_currency=840)
        updated_before = xrate.updated
        self.assertEqual(xrate.rate, 1.0)

        api.update_rate(1000, 840)

        xrate = models.XRate.get(from_currency=1000, to_currency=840)
        update_after = xrate.updated

        self.assertGreater(xrate.rate, 5000)
        self.assertGreater(update_after, updated_before)

        api_log = models.ApiLog.select().order_by(models.ApiLog.created.desc()).first()

        self.assertIsNotNone(api_log)
        self.assertEqual(api_log.request_url, "https://api.privatbank.ua/p24api/pubinfo?exchange&json&coursid=11")
Beispiel #2
0
    def test_cdr(self):
        xrate = models.XRate.get(from_currency=840, to_currency=643)
        update_before = xrate.updated
        self.assertEqual(xrate.rate, 1.0)

        api.update_rate(840, 643)

        xrate = models.XRate.get(from_currency=840, to_currency=643)
        updated_after = xrate.updated

        self.assertGreater(xrate.rate, 60)
        self.assertGreater(updated_after, update_before)

        api_log = models.ApiLog.select().order_by(models.ApiLog.created.desc()).first()

        self.assertIsNotNone(api_log)
        self.assertEqual(api_log.request_url, "http://www.cbr.ru/scripts/XML_daily.asp")
        self.assertIsNotNone(api_log.response_text)
        self.assertIn("<NumCode>840</NumCode>", api_log.response_text)
Beispiel #3
0
    def test_privat_usd(self):
        xrate = models.XRate.get(id=1)
        updated_before = xrate.updated
        self.assertEqual(xrate.rate, 1.0)

        api.update_rate(840, 980)

        xrate = models.XRate.get(id=1)
        update_after = xrate.updated

        self.assertGreater(xrate.rate, 25)
        self.assertGreater(update_after, updated_before)

        api_log = models.ApiLog.select().order_by(models.ApiLog.created.desc()).first()

        self.assertIsNotNone(api_log)
        self.assertEqual(api_log.request_url, "https://api.privatbank.ua/p24api/pubinfo?exchange&json&coursid=11")
        self.assertIsNotNone(api_log.response_text)
        self.assertIn('{"ccy":"USD","base_ccy":"UAH",', api_log.response_text)
Beispiel #4
0
    def test_cryptonator_uah(self):
        from_currency = 1000
        to_currency = 980
        xrate = models.XRate.get(from_currency=from_currency, to_currency=to_currency)
        updated_before = xrate.updated
        self.assertEqual(xrate.rate, 1.0)

        api.update_rate(from_currency, to_currency)

        xrate = models.XRate.get(from_currency=from_currency, to_currency=to_currency)
        updated_after = xrate.updated

        self.assertGreater(xrate.rate, 150000)
        self.assertGreater(updated_after, updated_before)

        api_log = models.ApiLog.select().order_by(models.ApiLog.created.desc()).first()

        self.assertIsNotNone(api_log)
        self.assertEqual(api_log.request_url, "https://api.cryptonator.com/api/ticker/btc-uah")
        self.assertIsNotNone(api_log.response_text)

        self.assertIn('{"base":"BTC","target":"UAH","price":', api_log.response_text)