ShelterApp / AddResources

http://shelterapp.org/
11 stars 10 forks source link

Add testing suite and adjust IRS scraper accordingly #11

Closed hkuffel closed 3 years ago

hkuffel commented 3 years ago

I've added a testing suite using pytest to cover the IRS scraper and future scrapers once they're built. Currently all the tests pass, though I had to modify the scraper somewhat to get to that point. Although it's technically bad practice, one of the tests, which tests the fuzzy matching capability, uses the real MongoDB connection within it. It creates a new collection and destroys it within the test, however, so no real data is ever touched.

I did this because the fuzzy matching function uses the $text operator, and this operator isn't covered within mongomock, which is, as far as I know, the standard for testing against Mongo databases. Because the test uses the real connection, you'll need to add the db username and password as environment variables if you want it to pass. I've applied a custom marker to this test though, so if you want to skip it, you can do so with the command pytest -v -m "no realclient.

Happy to field more questions here or via slack