2016-06-07 68 views
0

我正在为使用条纹进行付款的模块编写测试。我想模拟它不要向API发送查询。 我使用它的下一个代码,但仍然有API的查询。我不明白为什么?这样的查询会出现在条纹登录我运行测试,每次:我如何修补条纹订阅

/v1/customers/cus_*********/subscription 

有我的代码:

@patch('stripe.Subscription.save') 
def test_subscription(self, subscription_update): 
    subscription_update.return_value = self.convert_to_stripe_object({...}) 
    # there is test code 

什么是这种情况的原因以及如何修补该查询?谢谢你的帮助!

+0

' @patch( 'stripe.Plan.list') @patch( 'stripe.Customer.save') @patch( 'stripe.Customer.create') @补丁( 'stripe.Token.create') @patch( 'stripe.Customer.delete') @patch( 'stripe.Plan.create') @patch( 'stripe.Plan.delete') ' 我使用上述所有方法进行修补,并按照文档中的描述正常工作。这很奇怪,但我无法在这里找到所需的选项:https://stripe.com/docs/api/python#subscriptions – user1564009

回答

0

我找到了解决方案。我修补update_subscription功能:

@mock.patch.object(stripe.Customer, 'update_subscription', autospec=True)