This repository has been archived by the owner on Jul 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CloCkWeRX/refactor_feed_for_stability
Refactor feed for stability
- Loading branch information
Showing
8 changed files
with
6,027 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# TODO Shift to spec helper | ||
|
||
$: << "#{File.dirname(__FILE__)}/.." | ||
require 'atdisplanningalertsfeed' | ||
|
||
Bundler.require :development, :test | ||
|
||
require 'vcr' | ||
|
||
VCR.configure do |c| | ||
c.cassette_library_dir = 'spec/cassettes' | ||
c.allow_http_connections_when_no_cassette = true | ||
c.hook_into :webmock | ||
c.default_cassette_options = { record: :new_episodes } | ||
c.configure_rspec_metadata! | ||
end | ||
|
||
|
||
# | ||
describe ATDISPlanningAlertsFeed, :vcr do | ||
before :each do | ||
@options = { | ||
lodgement_date_start: Date.parse("2016-02-21"), | ||
lodgement_date_end: Date.parse("2016-03-22") | ||
} | ||
end | ||
context 'valid feed' do | ||
it 'should not error on empty feed' do | ||
records = ATDISPlanningAlertsFeed.save("http://mycouncil2.solorient.com.au/Horizon/@@horizondap_ashfield@@/atdis/1.0/", @options) | ||
|
||
expect(records.length).to eq 0 | ||
end | ||
end | ||
context 'dodgy pagination' do | ||
it 'should not error' do | ||
records = ATDISPlanningAlertsFeed.save("https://myhorizon.maitland.nsw.gov.au/Horizon/@@horizondap@@/atdis/1.0/", @options) | ||
|
||
expect(records.length).to eq 120 | ||
end | ||
end | ||
|
||
context 'really dodgy pagination' do | ||
it 'should not error' do | ||
records = ATDISPlanningAlertsFeed.save("https://da.kiama.nsw.gov.au/atdis/1.0/", @options) | ||
|
||
expect(records.length).to eq 43 | ||
end | ||
end | ||
|
||
context 'with a flakey service' do | ||
# TODO This spec should always force a RestClient::InternalServerError: 500 Internal Server Error | ||
it 'should not error' do | ||
@options.merge!({ | ||
flakey: true | ||
}) | ||
# TODO This doesn't work as expected (stackleveltoodeep), but the VCR cassette should work | ||
# allow_any_instance_of(ATDIS::Feed).to receive(:applications).and_raise(RestClient::InternalServerError.new("500 Internal Server Error")) | ||
|
||
url ="http://myhorizon.cootamundra.nsw.gov.au/Horizon/@@horizondap@@/atdis/1.0/" | ||
records = ATDISPlanningAlertsFeed.save(url, @options) | ||
|
||
# TODO Expectation that a HTTP 500 on the first page recovers gracefully | ||
expect(records.length).to eq 0 | ||
end | ||
|
||
it 'should not error half way through processing' do | ||
@options.merge!({ | ||
flakey: true | ||
}) | ||
|
||
# TODO This doesn't work as expected | ||
# But I have faked the response in the cassette | ||
# allow_any_instance_of(ATDIS::Models::Page).to receive(:next_page).and_raise(RestClient::InternalServerError.new("500 Internal Server Error")) | ||
|
||
# Yass isn't actually flakey, but Cootamundra is *too* flakey | ||
# This scenario replicates one page of many having an unhandled exception (seen in Horizon DAP feeds) | ||
url = "http://mycouncil.yass.nsw.gov.au/Horizon/@@horizondap@@/atdis/1.0/" | ||
records = ATDISPlanningAlertsFeed.save(url, @options) | ||
|
||
# TODO Expectation that a HTTP 500 on the second page still allows several errors to process | ||
expect(records.length).to eq 20 | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.