from django.test import TransactionTestCase 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": [ { "resourceId": "ssss", "currency": "GBP", "ownerName": "JSNOW LIMITED", "cashAccountType": "CACC", "status": "enabled", "maskedPan": None, "details": "Private Limited Company", "bban": "ssss", "name": None, "product": None, "bic": None, "recipient": "TODO", "account_id": "s-s-s-s-s", "aggregator_id": str(self.aggregator.id), "requisition_id": "3ba3e65d-f44c-4c4e-9e28-08cc080830f6", "account_number": {"sort_code": "04-00-04", "number": "00000002"}, }, { "resourceId": "ssss", "currency": "GBP", "ownerName": "John Snow Smith", "cashAccountType": "CACC", "status": "enabled", "maskedPan": None, "details": "Personal Account", "bban": "ssss", "name": None, "product": None, "bic": None, "recipient": "TODO", "account_id": "s-s-s-s-s", "aggregator_id": str(self.aggregator.id), "requisition_id": "3ba3e65d-f44c-4c4e-9e28-08cc080830f6", "account_number": {"sort_code": "04-00-04", "number": "00000001"}, }, ] } self.aggregator.currencies = ["GBP"] self.aggregator.save() 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", name="Monero", ) provider = Provider.objects.create( code="REVOLUT", name="Revolut", ) self.ad = Ad.objects.create( user=self.user, name="Test", text="Ad text", payment_details="Payment details", 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, 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( "GBP", account_info, self.ad, 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( "GBP", account_info, self.ad, real=True, ) expected = "CUSTOM PAYMENT" self.assertEqual(result, expected)