mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
parent
317e5c47da
commit
a4ecf7d305
3 changed files with 253 additions and 0 deletions
196
spec/data_fixtures/adioso_fare.json
Normal file
196
spec/data_fixtures/adioso_fare.json
Normal file
|
@ -0,0 +1,196 @@
|
|||
{
|
||||
"currency": "USD",
|
||||
"results": [
|
||||
{
|
||||
"cost": 431.74000000000001,
|
||||
"date": 1372032000,
|
||||
"route": [
|
||||
"PDX",
|
||||
"DFW",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 431.74000000000001,
|
||||
"date": 1372118400,
|
||||
"route": [
|
||||
"PDX",
|
||||
"DFW",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 341.72000000000003,
|
||||
"date": 1372204800,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 625.57000000000005,
|
||||
"date": 1372291200,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAX",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 348.14999999999998,
|
||||
"date": 1372377600,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 306.81,
|
||||
"date": 1372464000,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 307.73000000000002,
|
||||
"date": 1372550400,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 257.20999999999998,
|
||||
"date": 1372636800,
|
||||
"route": [
|
||||
"PDX",
|
||||
"DFW",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 245.27000000000001,
|
||||
"date": 1372723200,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 293.02999999999997,
|
||||
"date": 1372809600,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 194.74000000000001,
|
||||
"date": 1372896000,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 244.34999999999999,
|
||||
"date": 1372982400,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 305.88999999999999,
|
||||
"date": 1373068800,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 306.81,
|
||||
"date": 1373155200,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 248.94,
|
||||
"date": 1373241600,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 244.34999999999999,
|
||||
"date": 1373328000,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 245.27000000000001,
|
||||
"date": 1373414400,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 277.42000000000002,
|
||||
"date": 1373500800,
|
||||
"route": [
|
||||
"PDX",
|
||||
"DFW",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 297.63,
|
||||
"date": 1373587200,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 209.44,
|
||||
"date": 1373673600,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cost": 259.95999999999998,
|
||||
"date": 1373760000,
|
||||
"route": [
|
||||
"PDX",
|
||||
"LAS",
|
||||
"ORD"
|
||||
]
|
||||
}
|
||||
],
|
||||
"type": "calendar",
|
||||
"warnings": null
|
||||
}
|
19
spec/data_fixtures/adioso_parse.json
Normal file
19
spec/data_fixtures/adioso_parse.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"cost_max": null,
|
||||
"currency": "USD",
|
||||
"date_end": 1403740799,
|
||||
"date_start": 1372032000,
|
||||
"dest_codes": [
|
||||
"CGX",
|
||||
"MDW",
|
||||
"ORD",
|
||||
"GYY"
|
||||
],
|
||||
"duration_max": null,
|
||||
"origin_codes": [
|
||||
"PDX",
|
||||
"SLE"
|
||||
],
|
||||
"search_url": "http://api.adioso.com/v2/search/fares?currency=USD&date_end=1403740799&date_start=1372032000&dest_codes=CGX%2CMDW%2CORD%2CGYY&origin_codes=PDX%2CSLE",
|
||||
"segments_max": null
|
||||
}
|
38
spec/models/agents/adioso_agent_spec.rb
Normal file
38
spec/models/agents/adioso_agent_spec.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Agents::AdiosoAgent do
|
||||
before do
|
||||
stub_request(:get, /parse/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/adioso_parse.json")), :status => 200, :headers => {"Content-Type" => "text/json"})
|
||||
stub_request(:get, /fares/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/adioso_fare.json")), :status => 200, :headers => {"Content-Type" => "text/json"})
|
||||
@valid_params = {
|
||||
:start_date => "June 25 2013",
|
||||
:end_date => "July 15 2013",
|
||||
:from => "Portland",
|
||||
:to => "Chicago",
|
||||
:username => "xx",
|
||||
:password => "xx",
|
||||
:expected_update_period_in_days => "2"
|
||||
}
|
||||
|
||||
@checker = Agents::AdiosoAgent.new(:name => "somename", :options => @valid_params)
|
||||
@checker.user = users(:jane)
|
||||
@checker.save!
|
||||
end
|
||||
|
||||
describe "#check" do
|
||||
it "should check that initial run creates an event" do
|
||||
expect { @checker.check }.to change { Event.count }.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#working?" do
|
||||
it "checks if its generating events as scheduled" do
|
||||
expect(@checker).not_to be_working
|
||||
@checker.check
|
||||
expect(@checker.reload).to be_working
|
||||
three_days_from_now = 3.days.from_now
|
||||
stub(Time).now { three_days_from_now }
|
||||
expect(@checker).not_to be_working
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue