def test_charge(self, mock_charge): # Create a fake request object with the test data request = self.factory.post("/shop/checkout/") request.POST["card_number"] = "4242424242424242" request.POST["card_expiry_month"] = "06" request.POST["card_expiry_year"] = "2014" request.POST["billing_detail_street"] = "123 Evergreen Terrace" request.POST["billing_detail_city"] = "Springfield" request.POST["billing_detail_state"] = "WA" request.POST["billing_detail_postcode"] = "01234" request.POST["billing_detail_country"] = "USA" # Order form isn't used by stripe backend order_form = None # Create an order order = Order.objects.create(total=Decimal("22.37")) # Code under test stripe_api.process(request, order_form, order) # Assertion mock_charge.create.assert_called_with( amount=2237, currency="usd", card={'number': "4242424242424242", 'exp_month': "06", 'exp_year': "14", 'address_line1': "123 Evergreen Terrace", 'address_city': "Springfield", 'address_state': "WA", 'address_zip': "01234", 'country': "USA"})
def test_charge(self, mock_charge): # Create a fake request object with the test data request = self.factory.post("/shop/checkout/") request.POST["card_number"] = "4242424242424242" request.POST["card_expiry_month"] = "06" request.POST["card_expiry_year"] = "2014" request.POST["billing_detail_street"] = "123 Evergreen Terrace" request.POST["billing_detail_city"] = "Springfield" request.POST["billing_detail_state"] = "WA" request.POST["billing_detail_postcode"] = "01234" request.POST["billing_detail_country"] = "USA" # Order form isn't used by stripe backend order_form = None # Create an order order = Order.objects.create(total=Decimal("22.37")) # Code under test stripe_api.process(request, order_form, order) # Assertion mock_charge.create.assert_called_with( amount=2237, currency="usd", card={'number': "4242424242424242", 'exp_month': "06", 'exp_year': "14", 'address_line1': "123 Evergreen Terrace", 'address_city': "Springfield", 'address_state': "WA", 'address_zip': "01234", 'country': "USA"})