Move elevation to core config and clean up HTTP mocking in tests #2378
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
We've had a method to fetch the elevation from Google for a while now. This method was used by both the YR platform and Sun component to fetch the elevation of the location. This meant a request to Google APIs on startup unless a user passed in elevation to the configs of either platform or component.
This PR makes elevation a first class citizen of the config object in core and allow it to be set by configuring it in the
[homeassistant]
section of your config.Elevation will now be only automatically fetched when we detect core configuration missing it.
I also moved some of the config related code from bootstrap to config, where it belongs.
While writing tests for util.location, I went to use httpretty as recently introduced to test forecast.io. However after reading up on it I noticed that it does not officially support Python 3. As a move to consolidate our HTTP testing efforts, I decided to use requests-mock and migrate the tests that depend on either httpretty or betamax to requests-mock.
Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass