Ejemplo n.º 1
0
def test_email_update_success_email(load_email):
    """it should be able to identify and scrape data from a email update success email"""
    html = load_email('email-update-success-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'EMAIL_UPDATE_SUCCESS_EMAIL'

    assert actual == expected
Ejemplo n.º 2
0
def test_limit_modification_email(load_email):
    """it should be able to identify and scrape data from a identification by phone email"""
    html = load_email('limit-modification-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'LIMIT_MODIFICATION_EMAIL'

    assert actual == expected
Ejemplo n.º 3
0
def test_scrape_cash_withdrawal_alt_email(load_email):
    """it should be able to identify and scrape data from cash withdrawal alt email"""
    html = load_email('cash-withdrawal-alt-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'CASH_WITHDRAWAL_ALT_EMAIL'

    assert actual == expected
Ejemplo n.º 4
0
def test_notification_medium_change_email(load_email):
    """it should be able to identify and scrape data from a notification medium change email"""
    html = load_email('notification-medium-change-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'NOTIFICATION_MEDIUM_CHANGE_EMAIL'

    assert actual == expected
Ejemplo n.º 5
0
def test_cc_payment_third_parties_email(load_email):
    """it should be able to identify and scrape data from a credit card payment third parties email"""
    html = load_email('credit-card-payment-third-parties-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'CREDIT_CARD_PAYMENT_THIRD_PARTIES_EMAIL'

    assert actual == expected
Ejemplo n.º 6
0
def test_cc_email_change_confirmation_email(load_email):
    """it should be able to identify and scrape data from a email change confirmation email"""
    html = load_email('email-change-confirmation-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'EMAIL_CHANGE_CONFIRMATION_EMAIL'

    assert actual == expected
Ejemplo n.º 7
0
def test_banorte_movil_cancelation_email(load_email):
    """it should be able to identify and scrape data from a banorte movil cancelation email"""
    html = load_email('banorte-movil-cancelation-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'BANORTE_MOVIL_CANCELATION_EMAIL'

    assert actual == expected
Ejemplo n.º 8
0
def test_transfer_third_party_email(load_email):
    """it should be able to identify and scrape data from a transfer third party email"""
    html = load_email('transfer-third-party-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'TRANSFER_THIRD_PARTY_EMAIL'

    assert actual == expected
Ejemplo n.º 9
0
def test_spei_devolution_email(load_email):
    """it should be able to identify and scrape data from a spei devolution email"""
    html = load_email('spei-devolution-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'SPEI_DEVOLUTION_EMAIL'

    assert actual == expected
Ejemplo n.º 10
0
def test_spei_income_email(load_email):
    """it should be able to identify and scrape data from a spei income email"""
    html = load_email('spei-income-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'SPEI_INCOME_EMAIL'

    assert actual == expected
Ejemplo n.º 11
0
def test_service_payment_email(load_email):
    """it should be able to identify and scrape data from a service payment email"""
    html = load_email('service-payment-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'SERVICE_PAYMENT_EMAIL'

    assert actual == expected
Ejemplo n.º 12
0
def test_phone_recharge_email(load_email):
    """it should be able to identify and scrape data from a phone recharge email"""
    html = load_email('phone-recharge-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'PHONE_RECHARGE_EMAIL'

    assert actual == expected
Ejemplo n.º 13
0
def test_nip_change_email(load_email):
    """it should be able to identify and scrape data from a nip change email"""
    html = load_email('nip-change-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'NIP_CHANGE_EMAIL'

    assert actual == expected
Ejemplo n.º 14
0
def test_transfer_national_banks_spei_email(load_email):
    """it should be able to identify and scrape data from a transfer national banks email"""
    html = load_email('transfer-national-banks-spei-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'TRANSFER_NATIONAL_BANKS_SPEI_EMAIL'

    assert actual == expected
Ejemplo n.º 15
0
def test_contact_media_update_email(load_email):
    """it should be able to identify and scrape data from a contact media update email"""
    html = load_email('contact-media-update-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'CONTACT_MEDIA_UPDATE_EMAIL'

    assert actual == expected
Ejemplo n.º 16
0
def test_banco_en_linea_blocked_user_email(load_email):
    """it should be able to identify and scrape data from a banco en linea blocked user email"""
    html = load_email('banco-en-linea-blocked-user-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'BANCO_EN_LINEA_BLOCKED_USER_EMAIL'

    assert actual == expected
Ejemplo n.º 17
0
def test_third_party_account_registration_email(load_email):
    """it should be able to identify and scrape data from a third party account registration email"""
    html = load_email('third-party-account-registration-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'THIRD_PARTY_ACCOUNT_REGISTRATION_EMAIL'

    assert actual == expected
Ejemplo n.º 18
0
def test_scrape_id_by_phone_email(load_email):
    """it should be able to identify and scrape data from a identification by phone email"""
    html = load_email('identification-by-phone-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'IDENTIFICATION_BY_PHONE_EMAIL'

    assert actual == expected
Ejemplo n.º 19
0
def test_ddc_canceled_email(load_email):
    """it should be able to identify and scrape data from a digital debit card canceled email"""
    html = load_email('digital-debit-card-canceled-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'DIGITAL_DEBIT_CARD_CANCELED_EMAIL'

    assert actual == expected
Ejemplo n.º 20
0
def test_scrape_fast_transfer_banorte_email(load_email):
    """it should be able to identify and scrape data from a fast transfer email (banorte)"""
    html = load_email('fast-transfer-banorte-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'FAST_TRANSFER_EMAIL'

    assert actual == expected
Ejemplo n.º 21
0
def test_debit_card_blocked_email(load_email):
    """it should be able to identify and scrape data from a debit card blocked email"""
    html = load_email('debit-card-blocked-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'DEBIT_CARD_BLOCKED_EMAIL'

    assert actual == expected
Ejemplo n.º 22
0
def test_deposit_email(load_email):
    """it should be able to identify and scrape data from a deposit email"""
    html = load_email('deposit-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'DEPOSIT_EMAIL'

    assert actual == expected
Ejemplo n.º 23
0
def test_cc_payment_other_banks_email(load_email):
    """it should be able to identify and scrape data from a credit card payment other banks email"""
    html = load_email('credit-card-payment-other-banks-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'CREDIT_CARD_PAYMENT_OTHER_BANKS_EMAIL'

    assert actual == expected
Ejemplo n.º 24
0
def test_scrape_account_info_email(load_email):
    """it should be able to identify and scrape data from an account info email"""
    html = load_email('account-info-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'ACCOUNT_INFO_EMAIL'

    assert actual == expected
Ejemplo n.º 25
0
def test_scrape_charge_email(load_email):
    """it should be able to identify and scrape data from a charge email"""
    html = load_email('charge-email.html')
    actual = banorte_email.scrape(html).source
    expected = 'CHARGE_EMAIL'

    assert actual == expected
Ejemplo n.º 26
0
def handle(event, context):
    sns_event_content = json.loads(
        event['Records'][0]['Sns']['Message'])['content']
    email_content = email.message_from_bytes(
        base64.b64decode(sns_event_content),
        policy=policy.default).get_content()
    record = banorte_email.scrape(email_content)

    if record.type == records.ACCOUNT_OPERATION_TYPE:
        return {
            'success': False,
            'code': 'NotImplemented',
            'message':
            'Insertion of account operation records not implemented',
        }

    try:
        client = boto3.resource(
            'dynamodb',
            **{} if IS_AWS else {'endpoint_url': 'http://localhost:8000'})
        table = client.Table('gaston' if IS_AWS else 'gaston-local')
        item = _make_item(
            record,
            event['Records'][0]['Sns']['MessageId'],
            event['Records'][0]['Sns']['Timestamp'],
        )
        table.put_item(
            Item=item,
            ConditionExpression='attribute_not_exists(record_id)',
        )

        return {
            'success': True,
            'record': item,
        }
    except botocore.exceptions.ClientError as error:
        error_details = error.response['Error']

        return {
            'success': False,
            'code': error_details['Code'],
            'message': error_details['Message'],
        }
Ejemplo n.º 27
0
def test_scraper_not_implemented_exception():
    """it should throw when a scraper has not been implemented"""
    with pytest.raises(banorte_email.ScraperNotImplementedException) as excinfo:
        banorte_email.scrape('<a></a>')

    assert 'Scraper not implemented' in str(excinfo.value)
Ejemplo n.º 28
0
def test_multiple_matches_exception():
    """it should throw if there are multiple matches"""
    with pytest.raises(banorte_email.MultipleMatchesException) as exinfo:
        banorte_email.scrape('RETIRO DE EFECTIVO DISPOSICION DE EFECTIVO')

    assert 'Multiple matches: CASH_WITHDRAWAL_EMAIL, CASH_WITHDRAWAL_ALT_EMAIL' in str(exinfo.value)