Esempio n. 1
0
def test_process_mras_email(app, session):
    """Assert that an MRAS email msg is processed correctly."""
    # setup filing + business for email
    filing = email_prepped_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
Esempio n. 2
0
def test_process_bn_email(app, session):
    """Assert that a BN email msg is processed correctly."""
    # setup filing + business for email
    identifier = 'BC1234567'
    filing = email_prepped_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'] == []
Esempio n. 3
0
def test_incorp_notification(app, session, option):
    """Assert that the legal name is changed."""
    # setup filing + business for email
    filing = email_prepped_filing(session, 'BC1234567', '1', option)
    token = 'token'
    # test processor
    with patch.object(incorp_notification, '_get_pdfs',
                      return_value=[]) as mock_get_pdfs:
        email = incorp_notification.process(
            {
                'filingId': filing.id,
                'type': 'incorporationApplication',
                'option': option
            }, token)
        if option == 'filed':
            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] == 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
Esempio n. 4
0
def test_mras_notification(app, session):
    """Assert that the legal name is changed."""
    # setup filing + business for email
    filing = email_prepped_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'] == []
Esempio n. 5
0
def test_process_incorp_email(app, session, option):
    """Assert that an INCORP email msg is processed correctly."""
    # setup filing + business for email
    filing = email_prepped_filing(session, 'BC1234567', '1', option)
    token = '1'
    # test worker
    with patch.object(AccountService, 'get_bearer_token', return_value=token):
        with patch.object(incorp_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 == 'filed':
                    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
Esempio n. 6
0
def test_bn_notificaton(app, session):
    """Assert that the bn email processor builds the email correctly."""
    # setup filing + business for email
    identifier = 'BC1234567'
    filing = email_prepped_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'] == []