#nsad_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1310610136691376159
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Can you share anymore details? What specifically are you trying to test?
checkout_session_data = {
'payment_method_types': ['card'],
'locale': 'pt-BR',
'line_items': [{
'price': id,
'quantity': 1,
}],
'metadata': {
'user_id': request.user.pk,
'product_id': product_id,
'price_id': price_id,
},
'mode': 'subscription',
'success_url': success_url,
'cancel_url': cancel_url,
'customer_email': request.user.email,
}
checkout_session = stripe.checkout.Session.create(**checkout_session_data)
return redirect(checkout_session.url)
@patch('stripe.checkout.Session.create')
@patch('stripe_settings.views.Price.objects.get')
def test_create_checkout_session_price_exists(self, mock_price, mock_stripe_create):
mock_price.return_value = self.price
mock_stripe_create.return_value = {'url': 'https://checkout.stripe.com/test_session'}
response = self.client.get(reverse('create_checkout_session', args=[self.price.stripe_price_id]))
self.assertRedirects(response, 'https://checkout.stripe.com/test_session')
ERROR:
'dict' object has no attribute 'url'
'dict' object has no attribute 'url'
I don't really understand what this is trying to do. Not familiar with this testing lib
Looks like you're trying to mock an API response?
What is it that you want to test, exactly?
I am try to test checkout redirect url
That seems a bit unnecessary really. We don't really recommended testing the responses of our API calls
oks, i just need test using stripe-cli?
Well, what is it you want to test? url field will always have a value when ui_mode: 'hosted'
Asserting that is redundant really
okay