From 6e6b23da63013237a9d8f4ab17dc1c22efab3cab Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 16 Mar 2023 20:49:57 +0000 Subject: [PATCH] Finish tests for custom payment details --- core/clients/aggregator.py | 3 -- core/clients/aggregators/nordigen.py | 1 - core/tests/test_platform.py | 54 +++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/core/clients/aggregator.py b/core/clients/aggregator.py index 4ad7788..3e1c14e 100644 --- a/core/clients/aggregator.py +++ b/core/clients/aggregator.py @@ -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 diff --git a/core/clients/aggregators/nordigen.py b/core/clients/aggregators/nordigen.py index a073124..0f8c147 100644 --- a/core/clients/aggregators/nordigen.py +++ b/core/clients/aggregators/nordigen.py @@ -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: diff --git a/core/tests/test_platform.py b/core/tests/test_platform.py index a007dcf..1cf2fc6 100644 --- a/core/tests/test_platform.py +++ b/core/tests/test_platform.py @@ -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)