-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
KycConfig.get_connection_settings()
- Loading branch information
Showing
5 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from django.test import TestCase | ||
|
||
import pytest | ||
|
||
from corehq.apps.integration.kyc.models import KycConfig, UserDataStore | ||
from corehq.motech.models import ConnectionSettings | ||
|
||
DOMAIN = 'test-domain' | ||
|
||
|
||
class TestGetConnectionSettings(TestCase): | ||
|
||
def test_valid_without_connection_settings(self): | ||
config = KycConfig( | ||
domain=DOMAIN, | ||
user_data_store=UserDataStore.USER_CASE, | ||
) | ||
# Does not raise `django.db.utils.IntegrityError` | ||
config.save() | ||
|
||
def test_get_connection_settings(self): | ||
config = KycConfig( | ||
domain=DOMAIN, | ||
user_data_store=UserDataStore.USER_CASE, | ||
) | ||
assert ConnectionSettings.objects.count() == 0 | ||
|
||
connx = config.get_connection_settings() | ||
assert isinstance(connx, ConnectionSettings) | ||
# First call creates ConnectionSettings | ||
assert ConnectionSettings.objects.count() == 1 | ||
|
||
connx = config.get_connection_settings() | ||
assert isinstance(connx, ConnectionSettings) | ||
# Subsequent calls get existing ConnectionSettings | ||
assert ConnectionSettings.objects.count() == 1 | ||
|
||
def test_bad_config(self): | ||
config = KycConfig( | ||
domain=DOMAIN, | ||
user_data_store=UserDataStore.USER_CASE, | ||
provider='invalid', | ||
) | ||
with pytest.raises( | ||
ValueError, | ||
match="^Unable to determine connection settings for KYC provider " | ||
"'invalid'.$", | ||
): | ||
config.get_connection_settings() |
24 changes: 24 additions & 0 deletions
24
corehq/apps/integration/migrations/0009_alter_kycconfig_connection_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.2.18 on 2025-02-16 18:56 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("motech", "0017_connectionsettings_use_aes_cbc_encryption"), | ||
("integration", "0008_kycconfig_provider_kycconfig_unique_domain_provider"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="kycconfig", | ||
name="connection_settings", | ||
field=models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to="motech.connectionsettings", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters