Begin implementing per-requisition configuration
parent
4211d3c10a
commit
4d4406643f
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 4.1.7 on 2023-03-15 10:14
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0024_ad_send_reference'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Requisition',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('requisition_id', models.CharField(max_length=255)),
|
||||||
|
('payment_details', models.TextField()),
|
||||||
|
('transaction_source', models.CharField(choices=[('booked', 'Booked'), ('pending', 'Pending')], max_length=255)),
|
||||||
|
('aggregator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.aggregator')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.1.7 on 2023-03-15 10:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0025_requisition'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='requisition',
|
||||||
|
name='transaction_source',
|
||||||
|
field=models.CharField(choices=[('booked', 'Booked'), ('pending', 'Pending')], default='booked', max_length=255),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.1.7 on 2023-03-15 10:18
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0026_alter_requisition_transaction_source'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='requisition',
|
||||||
|
name='payment_details',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,32 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from core.clients.aggregator import AggregatorClient
|
||||||
|
from core.models import Aggregator, Platform, User
|
||||||
|
|
||||||
|
|
||||||
|
class AggregatorPlatformMixin:
|
||||||
|
def setUp(self):
|
||||||
|
logging.disable(logging.CRITICAL)
|
||||||
|
self.user = User.objects.create_user(
|
||||||
|
username="testuser", email="test@example.com", password="test"
|
||||||
|
)
|
||||||
|
self.aggregator = Aggregator.objects.create(
|
||||||
|
user=self.user,
|
||||||
|
name="Test",
|
||||||
|
service="nordigen",
|
||||||
|
secret_id="a",
|
||||||
|
secret_key="a",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.agg_client = AggregatorClient()
|
||||||
|
self.agg_client.instance = self.aggregator
|
||||||
|
|
||||||
|
self.platform = Platform.objects.create(
|
||||||
|
user=self.user,
|
||||||
|
name="Test",
|
||||||
|
service="agora",
|
||||||
|
token="a",
|
||||||
|
password="a",
|
||||||
|
otp_token="a",
|
||||||
|
username="myuser",
|
||||||
|
)
|
@ -0,0 +1,106 @@
|
|||||||
|
from django.test import TransactionTestCase
|
||||||
|
|
||||||
|
from core.clients.platforms.agora import AgoraClient
|
||||||
|
from core.models import Ad, Asset, Provider
|
||||||
|
from core.tests.helpers import AggregatorPlatformMixin
|
||||||
|
|
||||||
|
|
||||||
|
class TestPlatform(AggregatorPlatformMixin, TransactionTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
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.save()
|
||||||
|
|
||||||
|
self.plat_client = AgoraClient(self.platform)
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_valid_account_details(self):
|
||||||
|
result = self.plat_client.get_valid_account_details(self.ad)
|
||||||
|
|
||||||
|
def test_get_matching_account_details(self):
|
||||||
|
result = self.plat_client.get_matching_account_details("GBP", self.ad)
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
Loading…
Reference in New Issue