forked from cds-snc/notification-api
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#190] persist recipient identifiers to table
- Loading branch information
1 parent
766fe2e
commit b4a528f
Showing
5 changed files
with
64 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from notifications_utils.statsd_decorators import statsd | ||
|
||
from app import db | ||
from app.dao.dao_utils import transactional | ||
from app.models import RecipientIdentifiers | ||
|
||
|
||
@statsd(namespace="dao") | ||
@transactional | ||
def persist_recipient_identifiers(notification_id, va_identifier_type, va_identifier_value): | ||
recipient_identifiers = RecipientIdentifiers( | ||
notification_id=notification_id, | ||
va_identifier_type=va_identifier_type, | ||
va_identifier_value=va_identifier_value | ||
) | ||
db.session.add(recipient_identifiers) | ||
db.session.commit() |
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
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,27 @@ | ||
from app.dao.recipient_identifiers_dao import persist_recipient_identifiers | ||
from app.models import RecipientIdentifiers, VA_PROFILE_ID | ||
|
||
from tests.app.db import ( | ||
create_notification | ||
) | ||
|
||
|
||
def test_should_add_recipient_identifiers_to_recipient_identifiers_table(notify_api, sample_job, sample_email_template): | ||
notification = create_notification(to_field=None, job=sample_job, template=sample_email_template) | ||
notification_id = notification.id | ||
va_identifier_type = VA_PROFILE_ID | ||
va_identifier_value = "foo" | ||
|
||
persist_recipient_identifiers(notification_id, va_identifier_type, va_identifier_value) | ||
assert RecipientIdentifiers.query.count() == 1 | ||
assert RecipientIdentifiers.query.get((notification_id, va_identifier_type, va_identifier_value))\ | ||
.notification_id == notification_id | ||
assert RecipientIdentifiers.query.get((notification_id, va_identifier_type, va_identifier_value))\ | ||
.va_identifier_type == va_identifier_type | ||
assert RecipientIdentifiers.query.get((notification_id, va_identifier_type, va_identifier_value)) \ | ||
.va_identifier_value == va_identifier_value | ||
|
||
|
||
# def test_should_add_recipient_identifiers_to_recipient_identifiers_history(): | ||
|
||
# def test_should_have_access_to_recipient_identifiers_dict_from_notification(): |
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