braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
241 stars 155 forks source link

Recommended approach to unit/integration-tests for APIs wrapping this library #107

Closed somada141 closed 5 years ago

somada141 commented 5 years ago

General information

Issue description

To my understanding Braintree essentially requires developers to develop a wrapper API around this library for use with a given app (I'm working on an Angular 6 app with Python backend APIs) in order to create/retrieve customers, generate tokens, create transactions/subscriptions etc.

Given that I was wondering what your recommended approach to testing said API is (referring primarily to unit-tests and integration-tests).

I've noticed that this library is tested via a development environment against a server that's supposed to be running on localhost:3000. Is there any chance for that development variant of Braintree to be released in order to allow for integration testing without depending on mocks or actual sandboxes? Even having a closed-source binary that'd integrate with this library would be very useful.

Thanks a lot!

hollabaq86 commented 5 years ago

Hey @somada141, we can't expose a development version of the Braintree environment.

For unit testing we recommend mocking as you mentioned. When integration testing, you can clean up any customers or payment methods that were created from your test by deleting them from your Braintree sandbox account upon completion.

Please note, subscriptions can be canceled but not deleted, and transactions cannot be deleted. So if you have any logic that relies on the number of transactions/subscriptions using the search methods, I'd recommend scoping the search with a timestamp to limit them to the resources created by the tests.

If you have any additional questions, feel free to contact Braintree Support. This repo is for bugs regarding the python SDK and our Support team is better equipped to answer your integration testing questions.

somada141 commented 5 years ago

Thanks for the tips @hollabaq86. Appreciate it :)