-
Notifications
You must be signed in to change notification settings - Fork 0
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 #98 from MITLibraries/url-loader-for-terms
Add temporary url_loader for search events
- Loading branch information
Showing
3 changed files
with
91 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
require 'rake' | ||
|
||
class SearchEventLoaderRakeTest < ActiveSupport::TestCase | ||
def setup | ||
Tacos::Application.load_tasks if Rake::Task.tasks.empty? | ||
Rake::Task['search_events:csv_loader'].reenable | ||
end | ||
|
||
test 'csv_loader can accept a url and source parameter' do | ||
records_before = SearchEvent.count | ||
VCR.use_cassette('search_events:url_loader from remote csv') do | ||
remote_file = 'http://static.lndo.site/search_events.csv' | ||
Rake::Task['search_events:csv_loader'].invoke(remote_file, 'test') | ||
end | ||
|
||
assert_not_equal records_before, SearchEvent.count | ||
end | ||
|
||
test 'csv_loader errors without any parameters' do | ||
error = assert_raises(ArgumentError) do | ||
Rake::Task['search_events:csv_loader'].invoke | ||
end | ||
assert_equal 'Path is required', error.message | ||
end | ||
|
||
test 'csv_loader errors without a source parameter' do | ||
error = assert_raises(ArgumentError) do | ||
remote_file = 'http://static.lndo.site/search_events.csv' | ||
Rake::Task['search_events:csv_loader'].invoke(remote_file) | ||
end | ||
assert_equal 'Source is required', error.message | ||
end | ||
end |
41 changes: 41 additions & 0 deletions
41
test/vcr_cassettes/search_events_url_loader_from_remote_csv.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.