Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix broken geocoding test #1546

Merged
merged 1 commit into from Dec 8, 2021
Merged

Fix broken geocoding test #1546

merged 1 commit into from Dec 8, 2021

Conversation

TaiWilkin
Copy link
Contributor

@TaiWilkin TaiWilkin commented Dec 2, 2021

Overview

When geocoding a facility, if the country code returned by Google Maps
is different from the country code provided by the user, we throw a
ValueError.

We’re testing this code with an address that previously was getting
mapped by Google Maps to China, and testing that we threw an error
because the user had entered it as India. Google is now returning that
address as being in India, which means that a value error was
(correctly, but breaking the test) not raised.

The test now mocks the API response so that we are testing only our
own code, and not third-party responses.

Connects #1545

Demo

Broken test:
Screen Shot 2021-12-02 at 11 24 17 AM

Passing tests:
Screen Shot 2021-12-02 at 11 24 57 AM

Notes

Only one of the three geocoding tests were breaking, but I switched to the mock for all three.

Testing Instructions

  • Run the tests and confirm they are all passing.
  • Visually confirm the mocked responses are reasonable given the tests' purposes.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

Copy link
Contributor

@jwalgran jwalgran left a comment

Choose a reason for hiding this comment

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

Confirmed. Nice use of the built-in mocking helpers.

It's not every day that you get to report a 135x performance boost :-)

Ran 3 tests in 1.058s
Ran 3 tests in 0.008s

@jwalgran jwalgran assigned TaiWilkin and unassigned jwalgran Dec 8, 2021
When geocoding a facility, if the country code returned by Google Maps
is different from the country code provided by the user, we throw a
ValueError.

We’re testing this code with an address that previously was getting
mapped by Google Maps to China, and testing that we threw an error
because the user had entered it as India. Google is now returning that
address as being in India, which means that a value error was
(correctly, but breaking the test) not raised.

The test now mocks the API response so that we are testing only our
own code, and not third-party responses.
@TaiWilkin
Copy link
Contributor Author

Thank you for reviewing!

@TaiWilkin TaiWilkin merged commit f384a10 into develop Dec 8, 2021
@TaiWilkin TaiWilkin deleted the tw/fix-geocoding-test branch December 8, 2021 17:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants