Add test for to and from timestamp parameter

This commit is contained in:
hartator 2016-07-30 14:09:46 -05:00
parent 30302eb214
commit bb59287bea

View File

@ -22,9 +22,9 @@ class WaybackMachineDownloaderTest < Minitest::Test
def test_file_list_by_timestamp def test_file_list_by_timestamp
file_expected = { file_expected = {
file_id: "Fs-06.jpg", file_id: "page.html",
file_url: "http://www.onlyfreegames.net:80/Fs-06.jpg", file_url: "http://www.onlyfreegames.net:80/page.html",
timestamp: 20060716125343 timestamp: 20060713153753
} }
assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-1] assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-1]
end end
@ -46,17 +46,17 @@ class WaybackMachineDownloaderTest < Minitest::Test
def test_file_list_exclude_filter_without_matches def test_file_list_exclude_filter_without_matches
@wayback_machine_downloader.exclude_filter = 'abc123' @wayback_machine_downloader.exclude_filter = 'abc123'
assert_equal 69, @wayback_machine_downloader.get_file_list_curated.size assert_equal 68, @wayback_machine_downloader.get_file_list_curated.size
end end
def test_file_list_exclude_filter_with_1_match def test_file_list_exclude_filter_with_1_match
@wayback_machine_downloader.exclude_filter = 'menu.html' @wayback_machine_downloader.exclude_filter = 'menu.html'
assert_equal 68, @wayback_machine_downloader.get_file_list_curated.size assert_equal 67, @wayback_machine_downloader.get_file_list_curated.size
end end
def test_file_list_exclude_filter_with_a_regex def test_file_list_exclude_filter_with_a_regex
@wayback_machine_downloader.exclude_filter = '/\.(gif|je?pg|bmp)$/i' @wayback_machine_downloader.exclude_filter = '/\.(gif|je?pg|bmp)$/i'
assert_equal 32, @wayback_machine_downloader.get_file_list_curated.size assert_equal 31, @wayback_machine_downloader.get_file_list_curated.size
end end
def test_file_download def test_file_download
@ -65,8 +65,14 @@ class WaybackMachineDownloaderTest < Minitest::Test
assert_includes linux_page.read, "Linux Games" assert_includes linux_page.read, "Linux Games"
end end
def test_timestamp_being_respected def test_from_timestamp_being_respected
@wayback_machine_downloader.timestamp = 20050716231334 @wayback_machine_downloader.from_timestamp = 20050716231334
file_url = @wayback_machine_downloader.get_file_list_curated["linux.htm"][:file_url]
assert_equal "http://www.onlyfreegames.net/linux.htm", file_url
end
def test_to_timestamp_being_respected
@wayback_machine_downloader.to_timestamp = 20050716231334
assert_nil @wayback_machine_downloader.get_file_list_curated["linux.htm"] assert_nil @wayback_machine_downloader.get_file_list_curated["linux.htm"]
end end