Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock the Census API for tests so that Actions doesn't actually hit the API when running tests #864

Merged
merged 22 commits into from
Oct 17, 2023

Conversation

robertmitchellv
Copy link
Collaborator

PULL REQUEST

Summary

Mock the Census API for tests so that Actions doesn't actually hit the API when running tests. If there is any kind of rate limiting or issue with the external API we don't want that to halt our ability to merge PRs.

Related Issue

Fixes #861

Additional Information

This is important so that when other tickets are completed and you want to merge to main you are not stopped because a unit test for code you're not working on is failing because it's actually hitting an external API and erroring out.

@robertmitchellv robertmitchellv self-assigned this Oct 13, 2023
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #864 (6a4bf40) into main (3d4b5ea) will decrease coverage by 0.04%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #864      +/-   ##
==========================================
- Coverage   96.40%   96.37%   -0.04%     
==========================================
  Files          46       46              
  Lines        2645     2645              
==========================================
- Hits         2550     2549       -1     
- Misses         95       96       +1     
Flag Coverage Δ
unit-tests 96.37% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

@robertmitchellv robertmitchellv marked this pull request as ready for review October 13, 2023 02:23
Copy link
Collaborator

@m-goggins m-goggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sooo much cleaner! 🚀

@robertmitchellv
Copy link
Collaborator Author

@emmastephenson rightly pointed out that there are also geocoding functions running in the fhir/geospatial/test_fhir_census_client.py that also need to be mocked; will work on that now

Copy link
Collaborator

@DanPaseltiner DanPaseltiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work @robertmitchellv. I'm going to have to read the docs on @pytest.fixture and use it the next time I'm writing unit tests. 🚀

containers/record-linkage/app/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@emmastephenson emmastephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for figuring out that other test!

tests/geospatial/test_census_geocode_client.py Outdated Show resolved Hide resolved
@robertmitchellv robertmitchellv merged commit 77942ac into main Oct 17, 2023
20 checks passed
@robertmitchellv robertmitchellv deleted the robert/mock-census-api-tests branch October 17, 2023 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock the Census API for tests so that Actions doesn't actually hit the API when running tests
4 participants