Move lookup rates into new Money library

This commit is contained in:
2022-02-22 20:06:56 +00:00
parent c15492f161
commit 74522342f7
4 changed files with 50 additions and 25 deletions

View File

@@ -6,6 +6,7 @@ from copy import deepcopy
from tests.common import fake_public_ads, cg_prices, expected_to_update
from agora import Agora
from markets import Markets
from money import Money
import util
@@ -22,7 +23,10 @@ class TestAgora(TestCase):
def setUp(self):
self.markets = Markets()
self.agora = Agora()
self.money = Money()
setattr(self.agora, "markets", self.markets)
setattr(self.money, "markets", self.markets)
setattr(self.agora, "money", self.money)
self.all_providers = [
"XOOM",
@@ -177,8 +181,8 @@ class TestAgora(TestCase):
util.last_online_recent.return_value = True
# Override get_price
self.agora.cg.get_price = MagicMock()
self.agora.cg.get_price.return_value = cg_prices
self.money.cg.get_price = MagicMock()
self.money.cg.get_price.return_value = cg_prices
enum_ads_return = self.agora.enum_public_ads("XMR", "USD", self.all_providers)
@@ -191,7 +195,7 @@ class TestAgora(TestCase):
ad.append(margin)
expected_return.append(ad)
lookup_rates_return = self.agora.lookup_rates(enum_ads_return)
lookup_rates_return = self.agora.money.lookup_rates(enum_ads_return) # TODO: do this properly
self.assertCountEqual(lookup_rates_return, expected_return)
def test_lookup_rates_not_usd(self):
@@ -219,5 +223,5 @@ class TestAgora(TestCase):
ad.append(margin)
expected_return.append(ad)
# Test specifying rates=
lookup_rates_return = self.agora.lookup_rates(enum_ads_return, rates=cg_prices)
lookup_rates_return = self.agora.money.lookup_rates(enum_ads_return, rates=cg_prices)
self.assertCountEqual(lookup_rates_return, expected_return)