Finish tests for custom payment details

master
Mark Veidemanis 2 years ago
parent 4d4406643f
commit 6e6b23da63
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -19,7 +19,6 @@ class AggregatorClient(ABC):
# #if account["account_id"] in self.banks
# }
# For each bank
print("ACCOUNT INFOS", account_infos)
for bank, accounts in account_infos.items():
# Iterate the accounts
for index, account in enumerate(list(accounts)):
@ -51,8 +50,6 @@ class AggregatorClient(ABC):
self.instance.currencies = currencies
self.instance.save()
print("INSTANCE ACCOUNT INFO", self.instance.account_info)
async def process_transactions(self, account_id, transactions):
if not transactions:
return False

@ -158,7 +158,6 @@ class NordigenClient(BaseClient, AggregatorClient):
else:
requisitions = [await self.get_requisition(requisition)]
print("REQS", requisitions)
for req in requisitions:
accounts = req["accounts"]
for account_id in accounts:

@ -1,14 +1,15 @@
from django.test import TransactionTestCase
from core.clients.platforms.agora import AgoraClient
from core.models import Ad, Asset, Provider
from core.clients.platform import LocalPlatformClient
from core.models import Ad, Asset, Provider, Requisition
from core.tests.helpers import AggregatorPlatformMixin
class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
def setUp(self):
super().setUp()
self.plat_client = LocalPlatformClient()
self.plat_client.instance = self.platform
self.aggregator.account_info = {
"MONZO_MONZGB2L": [
{
@ -49,10 +50,18 @@ class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
},
]
}
self.aggregator.currencies = ["GBP"]
self.aggregator.save()
self.plat_client = AgoraClient(self.platform)
self.expected_account_first = {
"sort_code": "04-00-04",
"number": "00000001",
"bank": "MONZO",
"recipient": "John Snow Smith",
"aggregator_id": str(self.aggregator.id),
"requisition_id": "3ba3e65d-f44c-4c4e-9e28-08cc080830f6",
}
asset = Asset.objects.create(
code="XMR",
@ -72,21 +81,44 @@ class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
payment_details_real="Payment details real",
payment_method_details="Payment method details",
dist_list="",
asset_list=[asset],
provider_list=[provider],
platforms=[self.platform],
aggregators=[self.aggregator],
# asset_list=asset,
# provider_list=provider,
# platforms=self.platform,
# aggregators=self.aggregator,
send_reference=True,
visible=True,
enabled=True,
# commit=False,
)
self.ad.asset_list.set([asset])
self.ad.provider_list.set([provider])
self.ad.platforms.set([self.platform])
self.ad.aggregators.set([self.aggregator])
self.ad.save()
self.req = Requisition.objects.create(
user=self.user,
aggregator=self.aggregator,
requisition_id="3ba3e65d-f44c-4c4e-9e28-08cc080830f6",
payment_details="CUSTOM PAYMENT",
)
def test_get_valid_account_details(self):
result = self.plat_client.get_valid_account_details(self.ad)
expected = (
["GBP"],
{"GBP": self.expected_account_first},
)
self.assertEqual(result, expected)
def test_get_matching_account_details(self):
result = self.plat_client.get_matching_account_details("GBP", self.ad)
self.assertEqual(result, self.expected_account_first)
def test_format_payment_details(self):
account_info = self.plat_client.get_matching_account_details("GBP", self.ad)
result = self.plat_client.format_payment_details(
@ -96,6 +128,9 @@ class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
real=False,
)
expected = "Payment details"
self.assertEqual(result, expected)
def test_format_payment_details_real(self):
account_info = self.plat_client.get_matching_account_details("GBP", self.ad)
result = self.plat_client.format_payment_details(
@ -104,3 +139,6 @@ class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
self.ad,
real=True,
)
expected = "CUSTOM PAYMENT"
self.assertEqual(result, expected)

Loading…
Cancel
Save