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

Update weather agent to support both Dark Sky and OpenWeather #2900

Closed
wants to merge 6 commits into from
Closed

Update weather agent to support both Dark Sky and OpenWeather #2900

wants to merge 6 commits into from

Conversation

johnmaguire
Copy link

@johnmaguire johnmaguire commented Nov 11, 2020

Fixes #2732 and #2895.

Choosing which weather provider to use is done via the service option
which was previously used in the WeatherAgent to support Wunderground
and Dark Sky simultaneously, until Wunderground ended support for their
API, at which time it was removed.

Since the WeatherAgent didn't require a service option for a while,
this diff takes the approach of defaulting to "forecastio" if no
service option is provided in order to avoid breaking configurations
prior to this change. However, the default service value for a new
configuration will be "openweather." Additionally, "forecastio" can be
explicitly specified, again to ensure compatibility with even older
configurations.

A note on testing - I am not a Ruby developer, so I am not quite sure
how best to add tests around the branching behavior that occurs in the
model method. Even worse, since I do not have a Dark Sky API key, I
cannot manually test it. I did manually test OpenWeather.

It would also be ideal to have tests which verify that the
translation of data occurs without error using fixtures from each
provider. Tests of this behavior did not already exist in
weather_agent_spec.rb, however OpenWeather is tested indirectly by
agent_spec.rb among other specs. You can find these tests easily by
searching for the OpenWeather data fixture's file name
("openweather.json").

If someone were interested in creating tests of this nature in
weather_agent_spec.rb, you can also find a fixture file for Dark Sky
at /spec/data_fixtures/weather.json in any commit
prior to the commits from #2848 (starting with
a61924f.)

if dark_sky?
# AFAIK, there is no warning-level log messages. In any case, I'd like to log this from validate_options but
# since the Agent doesn't exist yet, the Log record can't be created (no parent_id)
log "NOTICE: The DarkSky API will be disabled at the end of 2021; please switch to OpenWeather." if dark_sky?
Copy link
Author

@johnmaguire johnmaguire Nov 11, 2020

Choose a reason for hiding this comment

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

This was the reason for #2899. I am hoping this isn't too annoying.

- Updates the README clarifying support of OpenWeather, Dark Sky, and
  Wunderground.
- Merges pull request #2848's support for OpenWeather in, without
  removing support for Dark Sky as the original pull request did.
  (Thanks Ryan Waldron for this!)

Choosing which weather provider to use is done via the `service` option
which was previously used in the WeatherAgent to support Wunderground
and Dark Sky simultaneously, until Wunderground ended support for their
API, at which time it was removed.

Since the WeatherAgent didn't require a `service` option for a while,
this diff takes the approach of defaulting to "forecastio" if no
`service` option is provided in order to avoid breaking configurations
prior to this change. However, the default `service` value for a new
configuration will be "openweather." Additionally, "forecastio" can be
explicitly specified, again to ensure compatibility with even older
configurations.

A note on testing - I am not a Ruby developer, so I am not quite sure
how best to add tests around the branching behavior that occurs in the
`model` method. Even worse, since I do not have a Dark Sky API key, I
cannot manually test it. I did manually test OpenWeather.

It would also be ideal to have tests which verify that the
translation of data occurs without error using fixtures from each
provider. Tests of this behavior did not already exist in
`weather_agent_spec.rb`, however OpenWeather  is tested indirectly by
`agent_spec.rb` among other specs. You can find these tests easily by
searching for the OpenWeather data fixture's file name
("openweather.json").

If someone were interested in creating tests of this nature in
`weather_agent_spec.rb`, you can also find a fixture file for Dark Sky
at `/spec/data_fixtures/weather.json` in any commit
prior to the commits from #2848 (starting with
a61924f.)
@johnmaguire
Copy link
Author

I closed this PR because there is apparently no interest in it.

This pull request was closed.
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.

Dark Sky End of Life: 2021
2 participants