2020-01-28 00:51:59 +01:00
|
|
|
from humblebundle_downloader.download_library import DownloadLibrary
|
|
|
|
|
|
|
|
|
2020-02-22 19:54:57 +01:00
|
|
|
###
|
|
|
|
# _should_download_file_type
|
|
|
|
###
|
2020-01-28 00:51:59 +01:00
|
|
|
def test_include_logic_has_values():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
|
|
|
ext_include=["pdf", "EPub"],
|
2020-01-28 00:51:59 +01:00
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_file_type("pdf") is True
|
|
|
|
assert dl._should_download_file_type("df") is False
|
|
|
|
assert dl._should_download_file_type("ePub") is True
|
|
|
|
assert dl._should_download_file_type("mobi") is False
|
2020-01-28 00:51:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_include_logic_empty():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
2020-01-28 00:51:59 +01:00
|
|
|
ext_include=[],
|
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_file_type("pdf") is True
|
|
|
|
assert dl._should_download_file_type("df") is True
|
|
|
|
assert dl._should_download_file_type("EPub") is True
|
|
|
|
assert dl._should_download_file_type("mobi") is True
|
2020-01-28 00:51:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_exclude_logic_has_values():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
|
|
|
ext_exclude=["pdf", "EPub"],
|
2020-01-28 00:51:59 +01:00
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_file_type("pdf") is False
|
|
|
|
assert dl._should_download_file_type("df") is True
|
|
|
|
assert dl._should_download_file_type("ePub") is False
|
|
|
|
assert dl._should_download_file_type("mobi") is True
|
2020-01-28 00:51:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_exclude_logic_empty():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
2020-01-28 00:51:59 +01:00
|
|
|
ext_exclude=[],
|
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_file_type("pdf") is True
|
|
|
|
assert dl._should_download_file_type("df") is True
|
|
|
|
assert dl._should_download_file_type("EPub") is True
|
|
|
|
assert dl._should_download_file_type("mobi") is True
|
2020-02-22 19:54:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# _should_download_platform
|
|
|
|
###
|
|
|
|
def test_download_platform_filter_none():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
2020-02-22 19:54:57 +01:00
|
|
|
platform_include=None,
|
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_platform("ebook") is True
|
|
|
|
assert dl._should_download_platform("audio") is True
|
2020-02-22 19:54:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_download_platform_filter_blank():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
2020-02-22 19:54:57 +01:00
|
|
|
platform_include=[],
|
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_platform("ebook") is True
|
|
|
|
assert dl._should_download_platform("audio") is True
|
2020-02-22 19:54:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_download_platform_filter_audio():
|
|
|
|
dl = DownloadLibrary(
|
2024-08-01 01:59:58 +02:00
|
|
|
"fake_library_path",
|
|
|
|
platform_include=["audio"],
|
2020-02-22 19:54:57 +01:00
|
|
|
)
|
2024-08-01 01:59:58 +02:00
|
|
|
assert dl._should_download_platform("ebook") is False
|
|
|
|
assert dl._should_download_platform("audio") is True
|