impactlab / eemeter

‼️ MOVED TO https://github.com/openeemeter/eemeter - Core computation engine for the Open Energy Efficiency Meter
https://eemeter.readthedocs.io/
MIT License
25 stars 13 forks source link

mock external dependencies during tests #134

Open crolfe opened 8 years ago

crolfe commented 8 years ago

I noticed that running the tests results in real FTP connections, which means tests will fail if the external FTP site is down or not connected to the Internet (plus it isn't very polite to the external service).

If we mock out the FTP connection code to return a simulated response, then the tests should be less brittle and should (hopefully) run quite a bit faster.

philngo commented 8 years ago

Yes - agreed. We could try to mock the FTP connections themselves, or we could make a mock NOAAClient, which just uses some mock data. I'm inclined to go for the latter - it's probably the simplest and most straightforward. I could try to throw in a stab at that into the 0.4 release candidate.

crolfe commented 8 years ago

Sounds good. I was hoping to find a testing library for ftplib that is similar to https://github.com/getsentry/responses for requests, but no such luck. responses does work well with pytest's fixtures, so I'd recommend it for testing HTTP requests.

Let me know if you need a hand with this.