Fix exact match logic and add a test

This commit is contained in:
Oleg Pudeyev 2017-06-03 17:45:06 -04:00
parent e166e9443d
commit 4af80adca6
2 changed files with 16 additions and 8 deletions

View File

@ -87,14 +87,12 @@ class WaybackMachineDownloader
snapshot_list_to_consider += get_raw_list_from_api(@base_url, nil) snapshot_list_to_consider += get_raw_list_from_api(@base_url, nil)
print "." print "."
unless @exact_match unless @exact_match
snapshot_list_to_consider += get_raw_list_from_api(@base_url + '/*', nil) @maximum_pages.times do |page_index|
print "." snapshot_list = get_raw_list_from_api(@base_url + '/*', page_index)
end break if snapshot_list.empty?
@maximum_pages.times do |page_index| snapshot_list_to_consider += snapshot_list
snapshot_list = get_raw_list_from_api(@base_url + '/*', page_index) print "."
break if snapshot_list.empty? end
snapshot_list_to_consider += snapshot_list
print "."
end end
puts " found #{snapshot_list_to_consider.lines.count} snaphots to consider." puts " found #{snapshot_list_to_consider.lines.count} snaphots to consider."
puts puts

View File

@ -39,6 +39,16 @@ class WaybackMachineDownloaderTest < Minitest::Test
assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-2] assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-2]
end end
def test_without_exact_match
@wayback_machine_downloader.exact_match = false
assert @wayback_machine_downloader.get_file_list_curated.size > 1
end
def test_exact_match
@wayback_machine_downloader.exact_match = true
assert_equal 1, @wayback_machine_downloader.get_file_list_curated.size
end
def test_file_list_only_filter_without_matches def test_file_list_only_filter_without_matches
@wayback_machine_downloader.only_filter = 'abc123' @wayback_machine_downloader.only_filter = 'abc123'
assert_equal 0, @wayback_machine_downloader.get_file_list_curated.size assert_equal 0, @wayback_machine_downloader.get_file_list_curated.size