Running tests not against the live HubSpot demo account
See original GitHub issueMy colleagues and I a currently working on extending the contacts API (as mentioned also in https://github.com/jpetrucciani/hubspot3/issues/39).
The tests for this (and other) API rely on HubSpot’s live demo account. This causes some problems. Mainly the tests are failing at the moment because the demo account has reached its daily limit. We need to wait until the next day, when the limit is reset, to run all tests, hoping is has not been exceeded again.
Furthermore the tests can fail when the live database does not contain the expected records. Two examples: When the database is flushed, all tests relying on the contact from the BASE_CONTACT
would fail. And if there are less than 20 records in the database, testing the limit parameter in the test test_get_all
will not fail but will not test anything useful either since there will always be less than 20 results, regardless of the parameter value.
As a solution we would suggest to mock the API calls and their responses in the current unit tests. We would include the necessary changes (at least for the contact API tests) in the following PR.
Let me know what do you think.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
Great that you are open changing the tests.
Regarding testing against the live API: Yes, but I would suggest to create a different set of tests (integration tests) for this purpose. The unit tests on the other hand would only test the integrity of the code itself.
As of the latest commit/release
3.2.17
, I’ve included my test account key in the tests, so we should be able to use that key for integration tests (so at least we can get the old tests back up and running on Travis!). I’ve also switched the CI to use tox across the three supported versions we’ve specified.I’m still on board with also building out a bunch of unit tests for the library that use your mocking methods - I’ll just start slowly writing out some new tests when I get some more time!