Reformat project
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,16 @@
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from json import loads
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
from json import loads
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
|
||||
from tests.common import fake_public_ads, cg_prices, expected_to_update
|
||||
import sources.agora
|
||||
import lib.markets
|
||||
import lib.money
|
||||
import util
|
||||
import settings
|
||||
import sources.agora
|
||||
import util
|
||||
from tests.common import cg_prices, expected_to_update, fake_public_ads
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
|
||||
class TestAgora(TestCase):
|
||||
@@ -20,7 +19,9 @@ class TestAgora(TestCase):
|
||||
with open("tests/data/agora_ads.json", "r") as f:
|
||||
for line in f.readlines():
|
||||
parsed = loads(line)
|
||||
self.test_return_data[(parsed[2], parsed[1], str(parsed[0]))] = parsed[3]
|
||||
self.test_return_data[(parsed[2], parsed[1], str(parsed[0]))] = parsed[
|
||||
3
|
||||
]
|
||||
|
||||
super().__init__(*args, *kwargs)
|
||||
|
||||
@@ -181,10 +182,14 @@ class TestAgora(TestCase):
|
||||
util.last_online_recent = MagicMock()
|
||||
util.last_online_recent.return_value = True
|
||||
|
||||
enum_ads_return = yield self.agora.enum_public_ads("XMR", "USD", self.all_providers)
|
||||
enum_ads_return = yield self.agora.enum_public_ads(
|
||||
"XMR", "USD", self.all_providers
|
||||
)
|
||||
|
||||
# Ensure there are no duplicates
|
||||
enum_ads_return_ids = [(x[0], x[1], x[2], x[3], x[4], x[5]) for x in enum_ads_return]
|
||||
enum_ads_return_ids = [
|
||||
(x[0], x[1], x[2], x[3], x[4], x[5]) for x in enum_ads_return
|
||||
]
|
||||
enum_ads_return_ids_dedup = set(enum_ads_return_ids)
|
||||
self.assertEqual(len(enum_ads_return_ids), len(enum_ads_return_ids_dedup))
|
||||
|
||||
@@ -243,7 +248,9 @@ class TestAgora(TestCase):
|
||||
ad.append(margin)
|
||||
expected_return.append(ad)
|
||||
|
||||
lookup_rates_return = self.agora.money.lookup_rates("agora", enum_ads_return) # TODO: do this properly
|
||||
lookup_rates_return = self.agora.money.lookup_rates(
|
||||
"agora", enum_ads_return
|
||||
) # TODO: do this properly
|
||||
self.assertCountEqual(lookup_rates_return, expected_return)
|
||||
|
||||
def test_lookup_rates_not_usd(self):
|
||||
@@ -271,5 +278,7 @@ class TestAgora(TestCase):
|
||||
ad.append(margin)
|
||||
expected_return.append(ad)
|
||||
# Test specifying rates=
|
||||
lookup_rates_return = self.agora.money.lookup_rates("agora", enum_ads_return, rates=cg_prices)
|
||||
lookup_rates_return = self.agora.money.lookup_rates(
|
||||
"agora", enum_ads_return, rates=cg_prices
|
||||
)
|
||||
self.assertCountEqual(lookup_rates_return, expected_return)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from json import loads
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
from json import loads
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
|
||||
from tests.common import fake_public_ads_lbtc, cg_prices, expected_to_update_lbtc
|
||||
import sources.localbitcoins
|
||||
import lib.markets
|
||||
import lib.money
|
||||
import util
|
||||
import settings
|
||||
import sources
|
||||
import sources.localbitcoins
|
||||
import util
|
||||
from tests.common import (cg_prices, expected_to_update_lbtc,
|
||||
fake_public_ads_lbtc)
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
|
||||
class TestLBTC(TestCase):
|
||||
@@ -21,7 +21,9 @@ class TestLBTC(TestCase):
|
||||
with open("tests/data/lbtc_ads.json", "r") as f:
|
||||
for line in f.readlines():
|
||||
parsed = loads(line)
|
||||
self.test_return_data[(parsed[2], parsed[1], str(parsed[0]))] = parsed[3]
|
||||
self.test_return_data[(parsed[2], parsed[1], str(parsed[0]))] = parsed[
|
||||
3
|
||||
]
|
||||
|
||||
super().__init__(*args, *kwargs)
|
||||
|
||||
@@ -126,10 +128,14 @@ class TestLBTC(TestCase):
|
||||
util.last_online_recent = MagicMock()
|
||||
util.last_online_recent.return_value = True
|
||||
|
||||
enum_ads_return = yield self.lbtc.enum_public_ads("BTC", "GBP", self.all_providers)
|
||||
enum_ads_return = yield self.lbtc.enum_public_ads(
|
||||
"BTC", "GBP", self.all_providers
|
||||
)
|
||||
|
||||
# Ensure there are no duplicates
|
||||
enum_ads_return_ids = [(x[0], x[1], x[2], x[3], x[4], x[5]) for x in enum_ads_return]
|
||||
enum_ads_return_ids = [
|
||||
(x[0], x[1], x[2], x[3], x[4], x[5]) for x in enum_ads_return
|
||||
]
|
||||
enum_ads_return_ids_dedup = set(enum_ads_return_ids)
|
||||
self.assertEqual(len(enum_ads_return_ids), len(enum_ads_return_ids_dedup))
|
||||
|
||||
@@ -187,7 +193,9 @@ class TestLBTC(TestCase):
|
||||
ad.append(margin)
|
||||
expected_return.append(ad)
|
||||
|
||||
lookup_rates_return = self.lbtc.money.lookup_rates("lbtc", enum_ads_return) # TODO: do this properly
|
||||
lookup_rates_return = self.lbtc.money.lookup_rates(
|
||||
"lbtc", enum_ads_return
|
||||
) # TODO: do this properly
|
||||
self.assertCountEqual(lookup_rates_return, expected_return)
|
||||
|
||||
def test_lookup_rates_not_usd(self):
|
||||
@@ -215,5 +223,7 @@ class TestLBTC(TestCase):
|
||||
ad.append(margin)
|
||||
expected_return.append(ad)
|
||||
# Test specifying rates=
|
||||
lookup_rates_return = self.lbtc.money.lookup_rates("lbtc", enum_ads_return, rates=cg_prices)
|
||||
lookup_rates_return = self.lbtc.money.lookup_rates(
|
||||
"lbtc", enum_ads_return, rates=cg_prices
|
||||
)
|
||||
self.assertCountEqual(lookup_rates_return, expected_return)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import logging
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
from tests.common import fake_public_ads, expected_to_update
|
||||
|
||||
import lib.markets
|
||||
from sources.agora import Agora
|
||||
import settings
|
||||
import logging
|
||||
from sources.agora import Agora
|
||||
from tests.common import expected_to_update, fake_public_ads
|
||||
|
||||
|
||||
class TestMarkets(TestCase):
|
||||
@@ -105,7 +106,9 @@ class TestMarkets(TestCase):
|
||||
expected_btc_to_update = [x for x in expected_to_update if x[2] == "BTC"]
|
||||
self.assertCountEqual(res_btc, expected_btc_to_update)
|
||||
|
||||
res_both = self.markets.get_new_ad_equations("agora", fake_public_ads, ["XMR", "BTC"])
|
||||
res_both = self.markets.get_new_ad_equations(
|
||||
"agora", fake_public_ads, ["XMR", "BTC"]
|
||||
)
|
||||
self.assertCountEqual(res_both, expected_to_update)
|
||||
|
||||
def test_format_ad(self):
|
||||
@@ -116,7 +119,9 @@ $PAYMENT$
|
||||
"sort_code": "02-03-04",
|
||||
"account_number": "0023-0045",
|
||||
}
|
||||
payment_details_text = self.markets.format_payment_details("GBP", payment_details)
|
||||
payment_details_text = self.markets.format_payment_details(
|
||||
"GBP", payment_details
|
||||
)
|
||||
ad_text = self.markets.format_ad("XMR", "GBP", payment_details_text)
|
||||
expected = """* Set **Country of recipient's bank** to **"United Kingdom"**
|
||||
Payment details will be released after verification has passed.
|
||||
@@ -130,7 +135,9 @@ If you've already completed verification, they will be sent immediately.
|
||||
"sort_code": "02-03-04",
|
||||
"account_number": "0023-0045",
|
||||
}
|
||||
payment_details_text = self.markets.format_payment_details("GBP", payment_details)
|
||||
payment_details_text = self.markets.format_payment_details(
|
||||
"GBP", payment_details
|
||||
)
|
||||
|
||||
expected = """Payment details will be released after verification has passed.
|
||||
If you've already completed verification, they will be sent immediately."""
|
||||
@@ -139,5 +146,7 @@ If you've already completed verification, they will be sent immediately."""
|
||||
expected_real = """* Sort code: **02-03-04**
|
||||
* Account number: **0023-0045**
|
||||
Please send in GBP."""
|
||||
payment_details_text_real = self.markets.format_payment_details("GBP", payment_details, real=True)
|
||||
payment_details_text_real = self.markets.format_payment_details(
|
||||
"GBP", payment_details, real=True
|
||||
)
|
||||
self.assertEqual(payment_details_text_real, expected_real)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from unittest import TestCase
|
||||
import lib.money
|
||||
import logging
|
||||
from unittest import TestCase
|
||||
|
||||
import lib.money
|
||||
|
||||
|
||||
class TestMoney(TestCase):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
|
||||
import lib.transactions
|
||||
import lib.money
|
||||
import lib.antifraud
|
||||
import lib.money
|
||||
import lib.transactions
|
||||
|
||||
|
||||
class TestTransactions(TestCase):
|
||||
@@ -57,7 +57,9 @@ class TestTransactions(TestCase):
|
||||
self.money = lib.money.Money()
|
||||
self.money.get_rates_all = MagicMock()
|
||||
self.money.get_rates_all.return_value = {"GBP": 0.8}
|
||||
self.transactions.money.get_acceptable_margins = self.money.get_acceptable_margins
|
||||
self.transactions.money.get_acceptable_margins = (
|
||||
self.money.get_acceptable_margins
|
||||
)
|
||||
|
||||
self.trades = {
|
||||
1: {
|
||||
|
||||
Reference in New Issue
Block a user