def test_process_mras_email(app, session): """Assert that an MRAS email msg is processed correctly.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', 'mras') token = '1' # run worker with patch.object(AccountService, 'get_bearer_token', return_value=token): with patch.object(worker, 'send_email', return_value='success') as mock_send_email: worker.process_email( { 'email': { 'filingId': filing.id, 'type': 'incorporationApplication', 'option': 'mras' } }, app) # check vals assert mock_send_email.call_args[0][0]['content'][ 'subject'] == 'BC Business Registry Partner Information' assert mock_send_email.call_args[0][0][ 'recipients'] == '*****@*****.**' assert mock_send_email.call_args[0][0]['content']['body'] assert mock_send_email.call_args[0][0]['content'][ 'attachments'] == [] assert mock_send_email.call_args[0][1] == token
def test_incorp_notification(app, session, status): """Assert that the legal name is changed.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', status) token = 'token' # test processor with patch.object(filing_notification, '_get_pdfs', return_value=[]) as mock_get_pdfs: email = filing_notification.process( { 'filingId': filing.id, 'type': 'incorporationApplication', 'option': status }, token) if status == 'PAID': assert '*****@*****.**' in email['recipients'] assert email['content'][ 'subject'] == 'Confirmation of Filing from the Business Registry' else: assert email['content'][ 'subject'] == 'Incorporation Documents from the Business Registry' assert '*****@*****.**' in email['recipients'] assert email['content']['body'] assert email['content']['attachments'] == [] assert mock_get_pdfs.call_args[0][0] == status assert mock_get_pdfs.call_args[0][1] == token assert mock_get_pdfs.call_args[0][2] == {'identifier': 'BC1234567'} assert mock_get_pdfs.call_args[0][3] == filing
def test_process_bn_email(app, session): """Assert that a BN email msg is processed correctly.""" # setup filing + business for email identifier = 'BC1234567' filing = prep_incorp_filing(session, identifier, '1', 'bn') business = Business.find_by_identifier(identifier) # sanity check assert filing.id assert business.id token = '1' # run worker with patch.object(AccountService, 'get_bearer_token', return_value=token): with patch.object(worker, 'send_email', return_value='success') as mock_send_email: worker.process_email( { 'email': { 'filingId': None, 'type': 'businessNumber', 'option': 'bn', 'identifier': 'BC1234567' } }, app) # check email values assert '*****@*****.**' in mock_send_email.call_args[0][0][ 'recipients'] assert '*****@*****.**' in mock_send_email.call_args[0][0][ 'recipients'] assert mock_send_email.call_args[0][0]['content']['subject'] == \ f'{business.legal_name} - Business Number Information' assert mock_send_email.call_args[0][0]['content']['body'] assert mock_send_email.call_args[0][0]['content'][ 'attachments'] == []
def test_correction_incorporation_notification(app, session, status, has_name_change_with_new_nr): """Assert that the legal name is changed.""" # setup filing + business for email original_filing = prep_incorp_filing(session, 'BC1234567', '1', status) token = 'token' business = Business.find_by_identifier('BC1234567') filing = prep_incorporation_correction_filing(session, business, original_filing.id, '1', status, has_name_change_with_new_nr) # test processor with patch.object(filing_notification, '_get_pdfs', return_value=[]) as mock_get_pdfs: email = filing_notification.process( {'filingId': filing.id, 'type': 'correction', 'option': status}, token) if status == 'PAID': assert '*****@*****.**' not in email['recipients'] assert email['content']['subject'] == 'Confirmation of Correction of Incorporation Application' assert 'Incorporation Application (Corrected)' in email['content']['body'] else: assert email['content']['subject'] == \ 'Incorporation Application Correction Documents from the Business Registry' assert '*****@*****.**' in email['recipients'] assert email['content']['body'] if has_name_change_with_new_nr: assert 'Incorporation Certificate (Corrected)' in email['content']['body'] else: assert 'Incorporation Certificate (Corrected)' not in email['content']['body'] assert email['content']['attachments'] == [] assert mock_get_pdfs.call_args[0][0] == status assert mock_get_pdfs.call_args[0][1] == token assert mock_get_pdfs.call_args[0][2] == {'identifier': 'BC1234567'} assert mock_get_pdfs.call_args[0][3] == filing
def test_process_ar_reminder_email(app, session): """Assert that the ar reminder notification can be processed.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', 'COMPLETED') business = Business.find_by_internal_id(filing.business_id) business.legal_type = 'BC' business.legal_name = 'test business' token = 'token' # test processor with patch.object(AccountService, 'get_bearer_token', return_value=token): with patch.object(ar_reminder_notification, 'get_recipient_from_auth', return_value='*****@*****.**'): with patch.object(worker, 'send_email', return_value='success') as mock_send_email: worker.process_email( { 'email': { 'businessId': filing.business_id, 'type': 'annualReport', 'option': 'reminder', 'arFee': '100', 'arYear': '2021' } }, app) call_args = mock_send_email.call_args assert call_args[0][0]['content'][ 'subject'] == 'test business 2021 Annual Report Reminder' assert call_args[0][0]['recipients'] == '*****@*****.**' assert call_args[0][0]['content']['body'] assert call_args[0][0]['content']['attachments'] == [] assert call_args[0][1] == token
def test_mras_notification(app, session): """Assert that the legal name is changed.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', 'mras') # run processor email = mras_notification.process( {'filingId': filing.id, 'type': 'incorporationApplication', 'option': 'mras'}) # check email values assert email['recipients'] == '*****@*****.**' assert email['content']['subject'] == 'BC Business Registry Partner Information' assert email['content']['body'] assert email['content']['attachments'] == []
def test_process_incorp_email(app, session, option): """Assert that an INCORP email msg is processed correctly.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', option) token = '1' # test worker with patch.object(AccountService, 'get_bearer_token', return_value=token): with patch.object(filing_notification, '_get_pdfs', return_value=[]) as mock_get_pdfs: with patch.object(worker, 'send_email', return_value='success') as mock_send_email: worker.process_email( { 'email': { 'filingId': filing.id, 'type': 'incorporationApplication', 'option': option } }, app) assert mock_get_pdfs.call_args[0][0] == option assert mock_get_pdfs.call_args[0][1] == token assert mock_get_pdfs.call_args[0][2] == { 'identifier': 'BC1234567' } assert mock_get_pdfs.call_args[0][3] == filing if option == 'PAID': assert '*****@*****.**' in mock_send_email.call_args[ 0][0]['recipients'] assert mock_send_email.call_args[0][0]['content']['subject'] == \ 'Confirmation of Filing from the Business Registry' else: assert mock_send_email.call_args[0][0]['content']['subject'] == \ 'Incorporation Documents from the Business Registry' assert '*****@*****.**' in mock_send_email.call_args[0][0][ 'recipients'] assert mock_send_email.call_args[0][0]['content']['body'] assert mock_send_email.call_args[0][0]['content'][ 'attachments'] == [] assert mock_send_email.call_args[0][1] == token
def test_bn_notificaton(app, session): """Assert that the bn email processor builds the email correctly.""" # setup filing + business for email identifier = 'BC1234567' filing = prep_incorp_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 '*****@*****.**' in email['recipients'] assert '*****@*****.**' in email['recipients'] assert email['content'][ 'subject'] == f'{business.legal_name} - Business Number Information' assert email['content']['body'] assert email['content']['attachments'] == []
def test_ar_reminder_notification(app, session): """Assert that the ar reminder notification can be processed.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', '1', 'COMPLETED') business = Business.find_by_internal_id(filing.business_id) business.legal_type = 'BC' business.legal_name = 'test business' token = 'token' # test processor with patch.object(ar_reminder_notification, 'get_recipient_from_auth', return_value='*****@*****.**') \ as mock_get_recipient_from_auth: email = ar_reminder_notification.process( { 'businessId': filing.business_id, 'type': 'annualReport', 'option': 'reminder', 'arFee': '100', 'arYear': 2021 }, token) assert email['content']['subject'] == 'test business 2021 Annual Report Reminder' assert '*****@*****.**' in email['recipients'] assert email['content']['body'] assert email['content']['attachments'] == [] assert mock_get_recipient_from_auth.call_args[0][0] == 'BC1234567' assert mock_get_recipient_from_auth.call_args[0][1] == token