|
|
|
@ -193,3 +193,31 @@ class TestAgora(TestCase):
|
|
|
|
|
|
|
|
|
|
lookup_rates_return = self.agora.lookup_rates(enum_ads_return)
|
|
|
|
|
self.assertCountEqual(lookup_rates_return, expected_return)
|
|
|
|
|
|
|
|
|
|
def test_lookup_rates_not_usd(self):
|
|
|
|
|
"""
|
|
|
|
|
Above test only tests USD which does not take into account Forex.
|
|
|
|
|
Let's test both, and additionaly specify our own rates.
|
|
|
|
|
"""
|
|
|
|
|
# Override enum_public_ads
|
|
|
|
|
self.agora.agora._api_call = self.mock_enum_public_ads_api_call
|
|
|
|
|
self.agora.last_online_recent = MagicMock()
|
|
|
|
|
self.agora.last_online_recent.return_value = True
|
|
|
|
|
|
|
|
|
|
# Override get_price
|
|
|
|
|
self.agora.cg.get_price = MagicMock()
|
|
|
|
|
self.agora.cg.get_price.return_value = cg_prices
|
|
|
|
|
|
|
|
|
|
enum_ads_return = self.agora.enum_public_ads("XMR", "EUR", self.all_providers)
|
|
|
|
|
|
|
|
|
|
expected_return = []
|
|
|
|
|
# Let's manually calculate what it's supposed to look like
|
|
|
|
|
price_xmr = cg_prices["monero"]["eur"]
|
|
|
|
|
for ad in deepcopy(enum_ads_return):
|
|
|
|
|
price = float(ad[2])
|
|
|
|
|
margin = round(price / price_xmr, 2)
|
|
|
|
|
ad.append(margin)
|
|
|
|
|
expected_return.append(ad)
|
|
|
|
|
# Test specifying rates=
|
|
|
|
|
lookup_rates_return = self.agora.lookup_rates(enum_ads_return, rates=cg_prices)
|
|
|
|
|
self.assertCountEqual(lookup_rates_return, expected_return)
|
|
|
|
|