I'm interested in this project and figured writing tests was a good opportunity to learn more about it. I saw code coverage was not at 100% - and so I focused on tests that would improve the coverage.
What
Write a test for the retry logic on connection error, with eventual success
Write a test for the retry logic on connection error - where max attempts are reached
Write a test for the retry logic on 5XX errors - where max attempts are reached
All of these tests are rather slow, so I mocked time.sleep to speed them up. Since that had good results, I tweaked the rate limiting test to also mock time.sleep - speeding up the tests.
Testing
Run the tests - verify they are not really slow
I used my other PR - https://github.com/closeio/closeio-api/pull/116 - to check the coverage of the new tests. These additional tests bump up the total coverage from 76% to 88%. There are opportunities for further improvement by removing some unreachable/dead code, but I didn't want to make any library changes.
Why
I'm interested in this project and figured writing tests was a good opportunity to learn more about it. I saw code coverage was not at 100% - and so I focused on tests that would improve the coverage.
What
time.sleep
to speed them up. Since that had good results, I tweaked the rate limiting test to also mocktime.sleep
- speeding up the tests.Testing