-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
21515 - MRAS & BN emails for continuation in and amalgamation #2966
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c30aab3
21515 - mras email initial commit
ketaki-deodhar 89d9d73
21515 - bn email
ketaki-deodhar d3d5c89
21515 - unit tests
ketaki-deodhar c6e8468
21515 - fix code issue
ketaki-deodhar c9d26ae
21515 - modify a function
ketaki-deodhar a1d05ea
21515 - modify logic to get filing
ketaki-deodhar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -34,10 +34,11 @@ def process(email_msg: dict) -> dict: | |
|
||
# get filing and business json | ||
business = Business.find_by_identifier(email_msg['identifier']) | ||
filing_type = 'incorporationApplication' | ||
if business.legal_type in [Business.LegalTypes.SOLE_PROP.value, Business.LegalTypes.PARTNERSHIP.value]: | ||
filing_type = 'registration' | ||
filing = (Filing.get_a_businesses_most_recent_filing_of_a_type(business.id, filing_type)) | ||
|
||
# get filings by types. There will be only one of the listed filing types at once | ||
filings = Filing.get_filings_by_types(business.id, ['amalgamationApplication', 'continuationIn', | ||
'incorporationApplication', 'registration']) | ||
filing = filings[0] | ||
corp_type = CorpType.find_by_id(business.legal_type) | ||
|
||
# render template with vars | ||
|
@@ -48,7 +49,7 @@ def process(email_msg: dict) -> dict: | |
) | ||
|
||
# get recipients | ||
recipients = get_recipients(email_msg['option'], filing.filing_json, filing_type=filing_type) | ||
recipients = get_recipients(email_msg['option'], filing.filing_json, filing_type=filing.filing_type) | ||
return { | ||
'recipients': recipients, | ||
'requestBy': '[email protected]', | ||
|
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
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 |
---|---|---|
|
@@ -17,10 +17,15 @@ | |
from legal_api.models import Business | ||
|
||
from entity_emailer.email_processors import bn_notification | ||
from tests.unit import prep_incorp_filing, prep_registration_filing | ||
from tests.unit import ( | ||
prep_amalgamation_filing, | ||
prep_continuation_in_filing, | ||
prep_incorp_filing, | ||
prep_registration_filing, | ||
) | ||
|
||
|
||
def test_bn_notificaton(app, session): | ||
def test_incorporation_bn_notificaton(app, session): | ||
"""Assert that the bn email processor builds the email correctly.""" | ||
# setup filing + business for email | ||
identifier = 'BC1234567' | ||
|
@@ -40,6 +45,46 @@ def test_bn_notificaton(app, session): | |
assert email['content']['attachments'] == [] | ||
|
||
|
||
def test_amalgamation_bn_notificaton(app, session): | ||
"""Assert bn notification email for Amalgamation filing.""" | ||
# setup filing + business for email | ||
identifier = 'BC1234567' | ||
filing = prep_amalgamation_filing(session, identifier, '1', 'bn', 'TED business') | ||
business = Business.find_by_identifier(identifier) | ||
# sanity check | ||
assert filing.id | ||
assert business.id | ||
# run processor | ||
email = bn_notification.process( | ||
{'filingId': None, 'type': 'businessNumber', 'option': 'bn', 'identifier': 'BC1234567'}) | ||
# check email values | ||
assert '[email protected]' in email['recipients'] | ||
assert '[email protected]' in email['recipients'] | ||
assert email['content']['subject'] == f'{business.legal_name} - Business Number Information' | ||
assert email['content']['body'] | ||
assert email['content']['attachments'] == [] | ||
|
||
|
||
def test_continuation_bn_notificaton(mocker, app, session): | ||
"""Assert bn notification email for Continuation filing.""" | ||
# setup filing + business for email | ||
identifier = 'BC1234567' | ||
filing = prep_continuation_in_filing(session, identifier, '1', 'bn') | ||
business = Business.find_by_identifier(identifier) | ||
# sanity check | ||
assert filing.id | ||
assert business.id | ||
# run processor | ||
email = bn_notification.process( | ||
{'filingId': None, 'type': 'businessNumber', 'option': 'bn', 'identifier': 'BC1234567'}) | ||
# check email values | ||
assert '[email protected]' in email['recipients'] | ||
assert '[email protected]' in email['recipients'] | ||
assert email['content']['subject'] == f'{business.legal_name} - Business Number Information' | ||
assert email['content']['body'] | ||
assert email['content']['attachments'] == [] | ||
|
||
|
||
def test_bn_move_notificaton(app, session): | ||
"""Assert that the bn move email processor builds the email correctly.""" | ||
# setup filing + business for email | ||
|
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 |
---|---|---|
|
@@ -13,11 +13,11 @@ | |
# limitations under the License. | ||
"""The Unit Tests for the mras email processor.""" | ||
from entity_emailer.email_processors import mras_notification | ||
from tests.unit import prep_incorp_filing | ||
from tests.unit import prep_amalgamation_filing, prep_continuation_in_filing, prep_incorp_filing | ||
|
||
|
||
def test_mras_notification(app, session): | ||
"""Assert that the legal name is changed.""" | ||
def test_incorporation_app_mras_notification(app, session): | ||
"""Assert mras notification email for Incorporation application filing.""" | ||
# setup filing + business for email | ||
filing = prep_incorp_filing(session, 'BC1234567', '1', 'mras') | ||
# run processor | ||
|
@@ -28,3 +28,32 @@ def test_mras_notification(app, session): | |
assert email['content']['subject'] == 'BC Business Registry Partner Information' | ||
assert email['content']['body'] | ||
assert email['content']['attachments'] == [] | ||
|
||
|
||
def test_amalgamation_mras_notification(app, session): | ||
"""Assert mras notification email for Amalgamation filing.""" | ||
# setup filing + business for email | ||
filing = prep_amalgamation_filing(session, 'BC1234567', '1', 'mras', 'TED business') | ||
# run processor | ||
email = mras_notification.process( | ||
{'filingId': filing.id, 'type': 'amalgamationApplication', 'option': 'mras'}) | ||
# check email values | ||
assert email['recipients'] == '[email protected]' | ||
assert email['content']['subject'] == 'BC Business Registry Partner Information' | ||
assert email['content']['body'] | ||
assert email['content']['attachments'] == [] | ||
|
||
|
||
def test_continuation_mras_notification(app, session): | ||
"""Assert mras notification email for Continuation In filing.""" | ||
# setup filing + business for email | ||
filing = prep_continuation_in_filing(session, 'BC1234567', '1', 'mras') | ||
|
||
# run processor | ||
email = mras_notification.process( | ||
{'filingId': filing.id, 'type': 'continuationIn', 'option': 'mras'}) | ||
# check email values | ||
assert email['recipients'] == '[email protected]' | ||
assert email['content']['subject'] == 'BC Business Registry Partner Information' | ||
assert email['content']['body'] | ||
assert email['content']['attachments'] == [] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add check for 'bn' here otherwise it would exit right away