@@ -193,6 +193,31 @@ def test_customer_create_user_with_plan(self, CreateMock, SyncMock, CreateAndPay
193193 self .assertTrue (SyncMock .called )
194194 self .assertTrue (CreateAndPayMock .called )
195195
196+ @patch ("pinax.stripe.actions.invoices.create_and_pay" )
197+ @patch ("pinax.stripe.actions.customers.sync_customer" )
198+ @patch ("stripe.Customer.create" )
199+ def test_customer_create_user_with_plan_and_quantity (self , CreateMock , SyncMock , CreateAndPayMock ):
200+ Plan .objects .create (
201+ stripe_id = "pro-monthly" ,
202+ name = "Pro ($19.99/month each)" ,
203+ amount = 19.99 ,
204+ interval = "monthly" ,
205+ interval_count = 1 ,
206+ currency = "usd"
207+ )
208+ CreateMock .return_value = dict (id = "cus_YYYYYYYYYYYYY" )
209+ customer = customers .create (self .user , card = "token232323" , plan = self .plan , quantity = 42 )
210+ self .assertEqual (customer .user , self .user )
211+ self .assertEqual (customer .stripe_id , "cus_YYYYYYYYYYYYY" )
212+ _ , kwargs = CreateMock .call_args
213+ self .assertEqual (kwargs ["email" ], self .user .email )
214+ self .assertEqual (kwargs ["source" ], "token232323" )
215+ self .assertEqual (kwargs ["plan" ], self .plan )
216+ self .assertEqual (kwargs ["quantity" ], 42 )
217+ self .assertIsNotNone (kwargs ["trial_end" ])
218+ self .assertTrue (SyncMock .called )
219+ self .assertTrue (CreateAndPayMock .called )
220+
196221 @patch ("stripe.Customer.retrieve" )
197222 def test_purge (self , RetrieveMock ):
198223 customer = Customer .objects .create (
0 commit comments