mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Ignore the fixture API key in WeatherAgent (#1694)
This commit is contained in:
parent
89cfe8e6a0
commit
0dd1c78ae0
2 changed files with 13 additions and 3 deletions
|
@ -57,11 +57,11 @@ module Agents
|
|||
default_schedule "8pm"
|
||||
|
||||
def working?
|
||||
event_created_within?((interpolated['expected_update_period_in_days'].presence || 2).to_i) && !recent_error_logs?
|
||||
event_created_within?((interpolated['expected_update_period_in_days'].presence || 2).to_i) && !recent_error_logs? && key_setup?
|
||||
end
|
||||
|
||||
def key_setup?
|
||||
interpolated['api_key'].present? && interpolated['api_key'] != "your-key"
|
||||
interpolated['api_key'].present? && interpolated['api_key'] != "your-key" && interpolated['api_key'] != "put-your-key-here"
|
||||
end
|
||||
|
||||
def default_options
|
||||
|
@ -102,7 +102,7 @@ module Agents
|
|||
def validate_options
|
||||
errors.add(:base, "service must be set to 'forecastio' or 'wunderground'") unless ["forecastio", "wunderground"].include?(weather_provider)
|
||||
errors.add(:base, "location is required") unless location.present?
|
||||
errors.add(:base, "api_key is required") unless key_setup?
|
||||
errors.add(:base, "api_key is required") unless interpolated['api_key'].present?
|
||||
errors.add(:base, "which_day selection is required") unless which_day.present?
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,16 @@ describe Agents::WeatherAgent do
|
|||
it "creates a valid agent" do
|
||||
expect(agent).to be_valid
|
||||
end
|
||||
|
||||
it "is valid with put-your-key-here or your-key" do
|
||||
agent.options['api_key'] = 'put-your-key-here'
|
||||
expect(agent).to be_valid
|
||||
expect(agent.working?).to be_falsey
|
||||
|
||||
agent.options['api_key'] = 'your-key'
|
||||
expect(agent).to be_valid
|
||||
expect(agent.working?).to be_falsey
|
||||
end
|
||||
|
||||
describe "#service" do
|
||||
it "doesn't have a Service object attached" do
|
||||
|
|
Loading…
Add table
Reference in a new issue