Esempio n. 1
0
    def test_stripe_card_basically_works(self, sc):
        active_card = {}
        active_card['last4'] = '1234'
        active_card['expiration_month'] = 10
        active_card['expiration_year'] = 2020
        active_card['address_line1'] = "123 Main Street"
        active_card['address_line2'] = "Box 2"
        active_card['address_state'] = "Confusion"
        active_card['address_zip'] = "90210"

        stripe_customer = sc.retrieve.return_value
        stripe_customer.id = 'deadbeef'
        stripe_customer.get = {'active_card': active_card}.get

        expected = {
            'id': 'deadbeef',
            'last4': '************1234',
            'expiration_month': 10,
            'expiration_year': 2020,
            'address_1': '123 Main Street',
            'address_2': 'Box 2',
            'state': 'Confusion',
            'zip': '90210'
        }
        card = billing.StripeCard('deadbeef')
        actual = dict([(name, card[name]) for name in expected])
        assert_equals(actual, expected)
Esempio n. 2
0
    def test_stripe_card_gives_empty_string_instead_of_KeyError(self, sc):
        stripe_customer = sc.retrieve.return_value
        stripe_customer.id = 'deadbeef'
        stripe_customer.get = {'active_card': {}}.get

        expected = ''
        actual = billing.StripeCard('deadbeef')['nothing']
        assert_equals(actual, expected)
Esempio n. 3
0
    def test_stripe_card(self, sc):
        active_card = {}
        active_card['last4'] = '1234'
        active_card['expiry_month'] = 10
        active_card['expiry_year'] = 2020
        active_card['address_line1'] = "123 Main Street"
        active_card['address_line2'] = "Box 2"
        active_card['address_state'] = "Confusion"
        active_card['address_zip'] = "90210"

        stripe_customer = sc.retrieve.return_value
        stripe_customer.id = self.stripe_customer_id
        stripe_customer.get = {'active_card': active_card}.get

        card = billing.StripeCard(self.stripe_customer_id)

        self.assertEqual(card['id'], 'deadbeef')
        self.assertEqual(card['last4'], "************1234")
        self.assertEqual(card['expiry'], '10/2020')
        self.assertEqual(card['address_1'], '123 Main Street')
        self.assertEqual(card['address_2'], 'Box 2')
        self.assertEqual(card['state'], 'Confusion')
        self.assertEqual(card['zip'], '90210')
        self.assertEqual(card['nothing'], '')