Beispiel #1
0
def test__format_blast_rdo():

    rdo = RDO(sf_connection=sf)
    rdo.referral_id = "1234"
    rdo.lead_source = "Stripe"
    rdo.contact_id = "0031700000BHQzBAAX"
    rdo.installment_period = "monthly"
    rdo.stripe_customer = "cus_78MqJSBejMN9gn"
    rdo.amount = 40
    rdo.name = "foo"
    rdo.installments = 0
    rdo.open_ended_status = "Open"
    rdo.description = "Monthly Blast Subscription"
    rdo.agreed_to_pay_fees = True
    rdo.type = "The Blast"
    rdo.billing_email = "*****@*****.**"
    rdo.blast_subscription_email = "*****@*****.**"
    rdo.quarantined = True

    response = rdo._format()

    expected_response = {
        "Referral_ID__c": "1234",
        "Encouraged_to_contribute_by__c": None,
        "npe03__Date_Established__c": today,
        "Lead_Source__c": "Stripe",
        "npe03__Contact__c": "0031700000BHQzBAAX",
        "npe03__Installment_Period__c": "monthly",
        "Stripe_Customer_ID__c": "cus_78MqJSBejMN9gn",
        "npe03__Amount__c": "40.00",
        "Name": "foo",
        "npe03__Installments__c": 0,
        "npe03__Open_Ended_Status__c": "Open",
        "Stripe_Description__c": "Monthly Blast Subscription",
        "Stripe_Agreed_to_pay_fees__c": True,
        "Type__c": "The Blast",
        "Billing_Email__c": "*****@*****.**",
        "Blast_Subscription_Email__c": "*****@*****.**",
        "npe03__Organization__c": None,
        "npe03__Recurring_Donation_Campaign__c": None,
        "Stripe_Card_Brand__c": None,
        "Stripe_Card_Last_4__c": None,
        "Stripe_Card_Expiration__c": None,
        "Quarantined__c": True,
    }

    response["Name"] = "foo"
    assert response == expected_response
Beispiel #2
0
def test__format_recurring_donation_decimal():

    rdo = RDO(sf_connection=sf)
    rdo.referral_id = "1234"
    rdo.encouraged_by = "Because I love the Trib!"
    rdo.lead_source = "Stripe"
    rdo.contact_id = "0031700000BHQzBAAX"
    rdo.installment_period = "monthly"
    rdo.stripe_customer = "cus_78MqJSBejMN9gn"
    rdo.amount = 9.15
    rdo.name = "foo"
    rdo.installments = 0
    rdo.open_ended_status = None
    rdo.description = "Texas Tribune Membership"
    rdo.agreed_to_pay_fees = True
    rdo.quarantined = True

    response = rdo._format()

    expected_response = {
        "Referral_ID__c": "1234",
        "npe03__Organization__c": None,
        "Billing_Email__c": None,
        "Encouraged_to_contribute_by__c": "Because I love the Trib!",
        "npe03__Date_Established__c": today,
        "Lead_Source__c": "Stripe",
        "Blast_Subscription_Email__c": None,
        "npe03__Contact__c": "0031700000BHQzBAAX",
        "npe03__Installment_Period__c": "monthly",
        "Stripe_Customer_ID__c": "cus_78MqJSBejMN9gn",
        "npe03__Amount__c": "9.15",
        "Name": "foo",
        "npe03__Installments__c": 0,
        "npe03__Open_Ended_Status__c": None,
        "Stripe_Description__c": "Texas Tribune Membership",
        "Stripe_Agreed_to_pay_fees__c": True,
        "Type__c": "Recurring Donation",
        "npe03__Recurring_Donation_Campaign__c": None,
        "Stripe_Card_Brand__c": None,
        "Stripe_Card_Expiration__c": None,
        "Stripe_Card_Last_4__c": None,
        "Quarantined__c": True,
    }
    response["Name"] = "foo"
    assert response == expected_response
Beispiel #3
0
def test__format_slack():

    opportunity = Opportunity(sf_connection=sf)
    opportunity.account_id = "0011700000BpR8PAAV"
    opportunity.amount = 9
    opportunity.encouraged_by = "Because I love the Trib!"
    opportunity.name = "D C ([email protected])"
    opportunity.stripe_id = "cus_78MqJSBejMN9gn"
    opportunity.agreed_to_pay_fees = True
    opportunity.referral_id = "1234"
    opportunity.lead_source = "Stripe"
    opportunity.description = "The Texas Tribune Membership"
    opportunity.stripe_customer = "cus_78MqJSBejMN9gn"

    rdo = RDO(sf_connection=sf)
    rdo.referral_id = "1234"
    rdo.encouraged_by = "Because I love the Trib!"
    rdo.lead_source = "Stripe"
    rdo.contact_id = "0031700000BHQzBAAX"
    rdo.installment_period = "yearly"
    rdo.stripe_customer = "cus_78MqJSBejMN9gn"
    rdo.amount = 100
    rdo.name = "foo"
    rdo.installments = 3
    rdo.open_ended_status = None
    rdo.description = "Texas Tribune Circle Membership"
    rdo.agreed_to_pay_fees = True
    rdo.type = "Giving Circle"

    contact = Contact(sf_connection=sf)
    contact.email = "*****@*****.**"
    contact.first_name = "D"
    contact.last_name = "C"
    contact.lead_source = "Stripe"
    contact.work_email = "*****@*****.**"

    account = Account(sf_connection=sf)
    account.name = "Acme Inc."
    account.website = "http://acme.com"
    account.shipping_street = "Street"
    account.shipping_city = "Austin"
    account.shipping_postalcode = "78701"
    account.shipping_state = "TX"
    account.record_type_name = "Household"

    actual = construct_slack_message(account=account,
                                     rdo=rdo,
                                     opportunity=None,
                                     contact=None)
    expected = "Acme Inc. pledged $100 [yearly] (Because I love the Trib!)"

    assert actual == expected

    actual = construct_slack_message(account=None,
                                     rdo=rdo,
                                     opportunity=None,
                                     contact=contact)
    expected = "D C pledged $100 [yearly] (Because I love the Trib!)"

    assert actual == expected

    actual = construct_slack_message(account=None,
                                     rdo=None,
                                     opportunity=opportunity,
                                     contact=contact)
    expected = "D C pledged $9 [one-time] (Because I love the Trib!)"

    assert actual == expected