Finish tests for custom payment details

This commit is contained in:
2023-03-16 20:49:57 +00:00
parent 4d4406643f
commit 6e6b23da63
3 changed files with 46 additions and 12 deletions

View File

@@ -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)