Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1722 -- Add more tests for fundraising webhook #1761

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ontowhee
Copy link
Contributor

@ontowhee ontowhee commented Nov 21, 2024

Fix for #1722

Added test for checkout_session_completed. The test fails when reverting the change in e995213.

New files are added in test_data. They were generated by calling calling stripe.Customer.list().data[0], stripe.PaymentIntent.list().data[0], etc.

  • customer.json
  • payment_intent.json
  • session_completed.json

The payment_succeeded webhook still needs a test, but I wanted a quick review to see if I've approached this correctly.

@bmispelon @alexgmin

@ontowhee ontowhee marked this pull request as draft November 21, 2024 21:26
customer.return_value = self.stripe_data("customer")
payment_intent.return_value = self.stripe_data("payment_intent")
event = self.stripe_data("session_completed")
WebhookHandler(event).handle()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason behind not using self.post_event() like the other tests and calling the class directly?

event = self.stripe_data("session_completed")
WebhookHandler(event).handle()
customer.assert_called_once()
payment_intent.assert_called_once()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinks that should also be tested:

  • That the email is sent. There's an example above, self.assertEqual(len(mail.outbox), 1)
  • That the response of the handler is the correct one, It should be a 204.
  • What happens if the DjangoHero instance doesn't exist (this should probably be a different test (or could be a new PR to add this to every event test since right now they don't check this case))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants