pittcsc / PittAPI

An API to easily get data from the University of Pittsburgh
https://pittapi.pittcsc.org
GNU General Public License v2.0
108 stars 33 forks source link

Unit tests should be hermetic #50

Closed cheesesashimi closed 6 years ago

cheesesashimi commented 7 years ago

I noticed your tests are making actual calls to Pitt's website each time they are run. While this does shield against API changes from Pitt's side, it does so at the expense of slowing down your test runs and increases the amount of traffic that Pitt's website may have.

Ideally, your unit tests should not make any network, disk, etc. calls. The use of a mocking framework such as Python's mock, will allow you to substitute mock objects which allow you to verify that they were called, what parameters they were called with, etc. Your unit tests should only test your code (within reason).

azharichenko commented 7 years ago

Thank you @cheesesashimi for this suggestion. I'm right now in the process of actually making this happen since the builds keep failing due to the current nature of our tests.