Enhancements to ABB handling (#621)

- Migrate download client handling from /prowlarr to /download. Moves
all torrent/usenet handling to app-level and gives ABB this
functionality.
- ABB Scraper now uses shared HTTP infrastructure instead of raw
requests, adding retry and proxy support
- Added author, age and bitrate info to ABB search results
- Added "best match" sorting option for releases
- Added size and bitrate sorting options for ABB
- Removed bundled default ABB hostname, must be configured by the user
- Added URL normalisation for ABB hostname
- Rearranged settings UI, moved download clients to its own section. 
- More tests
This commit is contained in:
Alex
2026-02-16 14:52:46 +00:00
committed by GitHub
parent dd6fd1e199
commit 7fdf55f5fd
42 changed files with 2640 additions and 2170 deletions
+70 -53
View File
@@ -2,13 +2,14 @@
Tests for AudiobookBay download handler.
"""
from pathlib import Path
from threading import Event
from unittest.mock import Mock, patch, MagicMock
from unittest.mock import patch, MagicMock
import pytest
from shelfmark.core.models import DownloadTask
from shelfmark.release_sources.audiobookbay.handler import AudiobookBayHandler
from shelfmark.release_sources.prowlarr.clients import (
from shelfmark.download.clients import (
DownloadStatus,
DownloadState,
)
@@ -64,21 +65,22 @@ class TestAudiobookBayHandlerDownload:
)
cancel_flag = Event()
recorder = ProgressRecorder()
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
assert result is None # Torrents don't return path immediately
with patch.object(AudiobookBayHandler, "_poll_and_complete", return_value=None) as mock_poll:
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
assert result is None
mock_extract_magnet.assert_called_once_with(
"https://audiobookbay.lu/abss/test-book/",
"audiobookbay.lu"
)
mock_client.add_download.assert_called_once()
assert "downloading" in recorder.statuses
mock_poll.assert_called_once()
assert "resolving" in recorder.statuses
@patch('shelfmark.release_sources.audiobookbay.handler.scraper.extract_magnet_link')
@patch('shelfmark.release_sources.audiobookbay.handler.get_client')
@@ -111,12 +113,17 @@ class TestAudiobookBayHandlerDownload:
cancel_flag = Event()
recorder = ProgressRecorder()
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(
AudiobookBayHandler,
"_wait_for_completed_path",
return_value=(Path("/path/to/book.m4b"), None),
):
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
assert result == "/path/to/book.m4b"
mock_client.add_download.assert_not_called()
@@ -151,16 +158,18 @@ class TestAudiobookBayHandlerDownload:
cancel_flag = Event()
recorder = ProgressRecorder()
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(AudiobookBayHandler, "_poll_and_complete", return_value=None) as mock_poll:
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
assert result is None
assert "downloading" in recorder.statuses
mock_client.add_download.assert_not_called()
mock_poll.assert_called_once()
@patch('shelfmark.release_sources.audiobookbay.handler.scraper.extract_magnet_link')
@patch('shelfmark.release_sources.audiobookbay.handler.get_client')
@@ -203,13 +212,18 @@ class TestAudiobookBayHandlerDownload:
)
cancel_flag = Event()
recorder = ProgressRecorder()
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(
AudiobookBayHandler,
"_wait_for_completed_path",
return_value=(None, "Could not locate existing download path"),
):
result = handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
assert result is None
assert recorder.last_status == "error"
@@ -353,12 +367,13 @@ class TestAudiobookBayHandlerCategory:
cancel_flag = Event()
recorder = ProgressRecorder()
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(AudiobookBayHandler, "_poll_and_complete", return_value=None):
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
# Verify category was passed
call_kwargs = mock_client.add_download.call_args.kwargs
@@ -368,7 +383,7 @@ class TestAudiobookBayHandlerCategory:
@patch('shelfmark.release_sources.audiobookbay.handler.get_client')
@patch('shelfmark.release_sources.audiobookbay.handler.config.get')
def test_category_selection_transmission_general(self, mock_config_get, mock_get_client, mock_extract_magnet):
"""Test fallback to general category for Transmission."""
"""Test Transmission audiobook category does not fall back to general category."""
mock_extract_magnet.return_value = "magnet:?xt=urn:btih:abc123"
def config_get(key, default=""):
@@ -394,16 +409,17 @@ class TestAudiobookBayHandlerCategory:
cancel_flag = Event()
recorder = ProgressRecorder()
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(AudiobookBayHandler, "_poll_and_complete", return_value=None):
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
# Verify general category was used
# Transmission audiobook downloads use only the audiobook category key.
call_kwargs = mock_client.add_download.call_args.kwargs
assert call_kwargs['category'] == "books"
assert call_kwargs['category'] is None
@patch('shelfmark.release_sources.audiobookbay.handler.scraper.extract_magnet_link')
@patch('shelfmark.release_sources.audiobookbay.handler.get_client')
@@ -430,12 +446,13 @@ class TestAudiobookBayHandlerCategory:
cancel_flag = Event()
recorder = ProgressRecorder()
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
with patch.object(AudiobookBayHandler, "_poll_and_complete", return_value=None):
handler.download(
task=task,
cancel_flag=cancel_flag,
progress_callback=recorder.progress_callback,
status_callback=recorder.status_callback,
)
# Verify no category was passed
call_kwargs = mock_client.add_download.call_args.kwargs
+98 -126
View File
@@ -4,7 +4,6 @@ Tests for AudiobookBay scraper functions.
from unittest.mock import Mock, patch
import pytest
import requests
from shelfmark.release_sources.audiobookbay import scraper
@@ -97,20 +96,15 @@ DETAIL_HTML_NO_TRACKERS = """
class TestSearchAudiobookbay:
"""Tests for the search_audiobookbay function."""
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_success(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_success(self, mock_config_get, mock_html_get):
"""Test successful search with results."""
mock_config_get.return_value = 1.0 # rate_limit_delay
mock_get_proxies.return_value = {}
# Mock response
mock_response = Mock()
mock_response.status_code = 200
mock_response.url = "https://audiobookbay.lu/page/1/?s=test+query&cat=undefined%2Cundefined"
mock_response.text = SAMPLE_SEARCH_HTML
mock_get.return_value = mock_response
mock_html_get.return_value = (
SAMPLE_SEARCH_HTML,
"https://audiobookbay.lu/page/1/?s=test+query&cat=undefined%2Cundefined",
)
results = scraper.search_audiobookbay("test query", max_pages=1, hostname="audiobookbay.lu")
@@ -120,115 +114,85 @@ class TestSearchAudiobookbay:
assert results[0]['language'] == "English"
assert results[0]['format'] == "M4B"
assert results[0]['bitrate'] == "128 Kbps"
assert results[0]['size'] == "500.00 MBs"
assert results[0]['size'] == "500.00 MB"
assert results[0]['posted_date'] == "01 Jan 2024"
assert results[0]['cover'] == "https://example.com/cover.jpg"
assert results[1]['title'] == "Another Test Book - Another Author"
assert results[1]['language'] == "Spanish"
assert results[1]['format'] == "MP3"
assert results[1]['size'] == "1.01 GBs"
assert results[1]['size'] == "1.01 GB"
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_pagination(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_pagination(self, mock_config_get, mock_html_get):
"""Test pagination through multiple pages."""
mock_config_get.return_value = 0.0 # No delay for faster tests
mock_get_proxies.return_value = {}
# First page response
mock_response_page1 = Mock()
mock_response_page1.status_code = 200
mock_response_page1.url = "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined"
mock_response_page1.text = SAMPLE_SEARCH_HTML
# Second page response (empty)
mock_response_page2 = Mock()
mock_response_page2.status_code = 200
mock_response_page2.url = "https://audiobookbay.lu/page/2/?s=test&cat=undefined%2Cundefined"
mock_response_page2.text = EMPTY_SEARCH_HTML
mock_get.side_effect = [mock_response_page1, mock_response_page2]
mock_html_get.side_effect = [
(SAMPLE_SEARCH_HTML, "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined"),
(EMPTY_SEARCH_HTML, "https://audiobookbay.lu/page/2/?s=test&cat=undefined%2Cundefined"),
]
results = scraper.search_audiobookbay("test", max_pages=2, hostname="audiobookbay.lu")
assert len(results) == 2 # Only from first page
assert mock_get.call_count == 2
assert mock_html_get.call_count == 2
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_empty(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_empty(self, mock_config_get, mock_html_get):
"""Test search with no results."""
mock_config_get.return_value = 1.0
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 200
mock_response.url = "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined"
mock_response.text = EMPTY_SEARCH_HTML
mock_get.return_value = mock_response
mock_html_get.return_value = (
EMPTY_SEARCH_HTML,
"https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined",
)
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 0
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_error_non_200(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_error_non_200(self, mock_config_get, mock_html_get):
"""Test error handling for non-200 status code."""
mock_config_get.return_value = 1.0
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 404
mock_get.return_value = mock_response
mock_html_get.return_value = ("", "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined")
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 0
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_redirect_to_homepage(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_redirect_to_homepage(self, mock_config_get, mock_html_get):
"""Test handling redirect to homepage (blocked/invalid search)."""
mock_config_get.return_value = 1.0
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 200
mock_response.url = "https://audiobookbay.lu" # Redirected to homepage
mock_response.text = EMPTY_SEARCH_HTML
mock_get.return_value = mock_response
mock_html_get.return_value = (
EMPTY_SEARCH_HTML,
"https://audiobookbay.lu", # Redirected to homepage
)
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 0
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_request_exception(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_request_exception(self, mock_config_get, mock_html_get):
"""Test handling request exceptions."""
mock_config_get.return_value = 1.0
mock_get_proxies.return_value = {}
mock_get.side_effect = requests.exceptions.RequestException("Connection error")
mock_html_get.return_value = ("", "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined")
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 0
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_relative_link(self, mock_config_get, mock_get_proxies, mock_get):
def test_search_audiobookbay_relative_link(self, mock_config_get, mock_html_get):
"""Test handling relative links in results."""
mock_config_get.return_value = 1.0
mock_get_proxies.return_value = {}
html_with_relative_link = """
<div class="post">
@@ -240,31 +204,65 @@ class TestSearchAudiobookbay:
</div>
"""
mock_response = Mock()
mock_response.status_code = 200
mock_response.url = "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined"
mock_response.text = html_with_relative_link
mock_get.return_value = mock_response
mock_html_get.return_value = (
html_with_relative_link,
"https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined",
)
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 1
assert results[0]['link'] == "https://audiobookbay.lu/abss/relative-link/"
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_exact_phrase_query(self, mock_config_get, mock_html_get):
"""Test exact phrase wrapping and encoding in search URL."""
mock_config_get.return_value = 0.0
mock_html_get.return_value = (
SAMPLE_SEARCH_HTML,
"https://audiobookbay.lu/page/1/?s=%22test+query%22",
)
results = scraper.search_audiobookbay(
"test query",
max_pages=1,
hostname="audiobookbay.lu",
exact_phrase=True,
)
assert len(results) == 2
requested_url = mock_html_get.call_args.args[0]
assert "s=%22test+query%22" in requested_url
assert "cat=undefined%2Cundefined" not in requested_url
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
@patch('shelfmark.release_sources.audiobookbay.scraper.config.get')
def test_search_audiobookbay_legacy_category_fallback(self, mock_config_get, mock_html_get):
"""Test fallback to legacy category query when primary search request fails."""
mock_config_get.return_value = 0.0
mock_html_get.side_effect = [
("", "https://audiobookbay.lu/page/1/?s=test"), # Primary fetch failed
(SAMPLE_SEARCH_HTML, "https://audiobookbay.lu/page/1/?s=test&cat=undefined%2Cundefined"),
]
results = scraper.search_audiobookbay("test", max_pages=1, hostname="audiobookbay.lu")
assert len(results) == 2
assert mock_html_get.call_count == 2
first_url = mock_html_get.call_args_list[0].args[0]
second_url = mock_html_get.call_args_list[1].args[0]
assert "cat=undefined%2Cundefined" not in first_url
assert "cat=undefined%2Cundefined" in second_url
class TestExtractMagnetLink:
"""Tests for the extract_magnet_link function."""
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_success(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_success(self, mock_html_get):
"""Test successful magnet link extraction."""
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 200
mock_response.text = SAMPLE_DETAIL_HTML
mock_get.return_value = mock_response
mock_html_get.return_value = SAMPLE_DETAIL_HTML
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
@@ -277,16 +275,10 @@ class TestExtractMagnetLink:
assert "udp%3A//tracker.openbittorrent.com%3A80" in magnet_link
assert "http%3A//tracker.example.com%3A8080" in magnet_link
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_fallback(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_fallback(self, mock_html_get):
"""Test fallback to default trackers when none found."""
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 200
mock_response.text = DETAIL_HTML_NO_TRACKERS
mock_get.return_value = mock_response
mock_html_get.return_value = DETAIL_HTML_NO_TRACKERS
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
@@ -299,16 +291,10 @@ class TestExtractMagnetLink:
# Should contain default trackers
assert "udp%3A//tracker.openbittorrent.com%3A80" in magnet_link
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_no_info_hash(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_no_info_hash(self, mock_html_get):
"""Test handling missing info hash."""
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 200
mock_response.text = "<html><body></body></html>"
mock_get.return_value = mock_response
mock_html_get.return_value = "<html><body></body></html>"
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
@@ -317,15 +303,10 @@ class TestExtractMagnetLink:
assert magnet_link is None
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_non_200(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_non_200(self, mock_html_get):
"""Test handling non-200 status code."""
mock_get_proxies.return_value = {}
mock_response = Mock()
mock_response.status_code = 404
mock_get.return_value = mock_response
mock_html_get.return_value = ""
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
@@ -334,13 +315,10 @@ class TestExtractMagnetLink:
assert magnet_link is None
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_request_exception(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_request_exception(self, mock_html_get):
"""Test handling request exceptions."""
mock_get_proxies.return_value = {}
mock_get.side_effect = requests.exceptions.RequestException("Connection error")
mock_html_get.return_value = ""
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
@@ -349,12 +327,9 @@ class TestExtractMagnetLink:
assert magnet_link is None
@patch('shelfmark.release_sources.audiobookbay.scraper.requests.get')
@patch('shelfmark.release_sources.audiobookbay.scraper.network.get_proxies')
def test_extract_magnet_link_cleans_info_hash(self, mock_get_proxies, mock_get):
@patch('shelfmark.release_sources.audiobookbay.scraper.downloader.html_get_page')
def test_extract_magnet_link_cleans_info_hash(self, mock_html_get):
"""Test that info hash whitespace is cleaned."""
mock_get_proxies.return_value = {}
html_with_whitespace = """
<html>
<body>
@@ -368,10 +343,7 @@ class TestExtractMagnetLink:
</html>
"""
mock_response = Mock()
mock_response.status_code = 200
mock_response.text = html_with_whitespace
mock_get.return_value = mock_response
mock_html_get.return_value = html_with_whitespace
magnet_link = scraper.extract_magnet_link(
"https://audiobookbay.lu/abss/test-book/",
+159 -2
View File
@@ -11,6 +11,8 @@ from shelfmark.release_sources.audiobookbay.source import (
AudiobookBaySource,
_map_language,
_generate_source_id,
_split_title_and_author,
_parse_bitrate_to_kbps,
)
@@ -54,6 +56,21 @@ class TestMapLanguage:
assert _map_language("\tFrench\n") == "fr"
class TestParseBitrate:
"""Tests for the _parse_bitrate_to_kbps function."""
def test_parse_bitrate_to_kbps(self):
"""Test normal bitrate parsing from ABB string values."""
assert _parse_bitrate_to_kbps("128 Kbps") == 128
assert _parse_bitrate_to_kbps("192kbps") == 192
def test_parse_bitrate_to_kbps_invalid(self):
"""Test invalid bitrate values return None."""
assert _parse_bitrate_to_kbps(None) is None
assert _parse_bitrate_to_kbps("") is None
assert _parse_bitrate_to_kbps("Unknown") is None
class TestGenerateSourceId:
"""Tests for the _generate_source_id function."""
@@ -77,11 +94,27 @@ class TestGenerateSourceId:
class TestAudiobookBaySource:
"""Tests for the AudiobookBaySource class."""
@pytest.fixture(autouse=True)
def configure_hostname(self, monkeypatch):
"""Provide a default ABB hostname for source.search tests."""
import shelfmark.release_sources.audiobookbay.source as source_module
original_get = source_module.config.get
def mock_get(key, default=None):
if key == "ABB_HOSTNAME":
return "audiobookbay.lu"
return original_get(key, default)
monkeypatch.setattr(source_module.config, "get", mock_get)
def test_is_available_enabled(self, monkeypatch):
"""Test is_available when enabled."""
def mock_get(key, default=False):
if key == "ABB_ENABLED":
return True
if key == "ABB_HOSTNAME":
return "audiobookbay.lu"
return default
import shelfmark.release_sources.audiobookbay.source as source_module
@@ -302,7 +335,7 @@ class TestAudiobookBaySource:
assert len(results) == 1
release = results[0]
assert release.source == "audiobookbay"
assert release.title == "Test Book - Test Author"
assert release.title == "Test Book"
assert release.format == "m4b"
assert release.language == "en"
assert release.size == "500.00 MBs"
@@ -314,9 +347,25 @@ class TestAudiobookBaySource:
assert release.extra['preview'] == "https://example.com/cover.jpg"
assert release.extra['detail_url'] == "https://audiobookbay.lu/abss/test-book/"
assert release.extra['bitrate'] == "128 Kbps"
assert release.extra['bitrate_value'] == 128
assert release.extra['posted_date'] == "01 Jan 2024"
assert release.extra['title_raw'] == "Test Book - Test Author"
assert release.extra['author'] == "Test Author"
assert release.extra['language_raw'] == "English"
def test_split_title_and_author(self):
"""Test title/author parsing from ABB title patterns."""
assert _split_title_and_author("Book Title - Author Name") == (
"Book Title", "Author Name"
)
assert _split_title_and_author("Book Title - Author Name - Narrator") == (
"Book Title - Author Name", "Narrator"
)
assert _split_title_and_author("Book Title") == ("Book Title", None)
assert _split_title_and_author(" Book Title - Author Name ") == (
"Book Title", "Author Name"
)
@patch('shelfmark.release_sources.audiobookbay.source.scraper.search_audiobookbay')
def test_search_handles_scraper_exception(self, mock_search):
"""Test that scraper exceptions are handled gracefully."""
@@ -413,16 +462,124 @@ class TestAudiobookBaySource:
assert call_args.kwargs['hostname'] == "audiobookbay.is"
assert call_args.kwargs['max_pages'] == 3
@patch('shelfmark.release_sources.audiobookbay.source.scraper.search_audiobookbay')
def test_search_exact_phrase_setting_forwarded(self, mock_search, monkeypatch):
"""Test that exact phrase setting is forwarded to scraper search."""
mock_search.return_value = [
{
"title": "Test Book - Test Author",
"link": "https://audiobookbay.lu/abss/test-book/",
"cover": None,
"language": "English",
"format": "M4B",
"bitrate": "128 Kbps",
"size": "500 MB",
"posted_date": "01 Jan 2024",
}
]
def mock_get(key, default=None):
if key == "ABB_HOSTNAME":
return "audiobookbay.lu"
if key == "ABB_EXACT_PHRASE":
return True
return default
import shelfmark.release_sources.audiobookbay.source as source_module
monkeypatch.setattr(source_module.config, "get", mock_get)
source = AudiobookBaySource()
book = BookMetadata(
provider="test",
provider_id="123",
title="Test Book",
authors=["Test Author"],
)
plan = ReleaseSearchPlan(
languages=["en"],
isbn_candidates=[],
author="Test Author",
title_variants=[ReleaseSearchVariant(title="Test Book", author="Test Author")],
grouped_title_variants=[],
)
source.search(book, plan, content_type="audiobook")
call_args = mock_search.call_args_list[0]
assert call_args.kwargs["exact_phrase"] is True
@patch('shelfmark.release_sources.audiobookbay.source.scraper.search_audiobookbay')
def test_search_falls_back_to_broad_when_exact_finds_no_results(self, mock_search, monkeypatch):
"""Test fallback to broad search when exact phrase search has no results."""
mock_search.side_effect = [
[],
[
{
"title": "Test Book - Test Author",
"link": "https://audiobookbay.lu/abss/test-book/",
"cover": None,
"language": "English",
"format": "M4B",
"bitrate": "128 Kbps",
"size": "500 MB",
"posted_date": "01 Jan 2024",
}
],
]
def mock_get(key, default=None):
if key == "ABB_HOSTNAME":
return "audiobookbay.lu"
if key == "ABB_EXACT_PHRASE":
return True
return default
import shelfmark.release_sources.audiobookbay.source as source_module
monkeypatch.setattr(source_module.config, "get", mock_get)
source = AudiobookBaySource()
book = BookMetadata(
provider="test",
provider_id="123",
title="Test Book",
authors=["Test Author"],
)
plan = ReleaseSearchPlan(
languages=["en"],
isbn_candidates=[],
author="Test Author",
title_variants=[ReleaseSearchVariant(title="Test Book", author="Test Author")],
grouped_title_variants=[],
)
results = source.search(book, plan, content_type="audiobook")
assert len(results) == 1
assert mock_search.call_count == 2
first_call = mock_search.call_args_list[0].kwargs
second_call = mock_search.call_args_list[1].kwargs
assert first_call["exact_phrase"] is True
assert second_call["exact_phrase"] is False
def test_get_column_config(self):
"""Test column configuration."""
source = AudiobookBaySource()
config = source.get_column_config()
assert config is not None
assert len(config.columns) == 3
assert len(config.columns) == 4
column_keys = [col.key for col in config.columns]
assert "language" in column_keys
assert "format" in column_keys
assert "extra.bitrate" in column_keys
assert "size" in column_keys
assert "seeders" not in column_keys # ABB doesn't show seeders
assert config.supported_filters == ["format", "language"]
bitrate_col = next(col for col in config.columns if col.key == "extra.bitrate")
assert bitrate_col.sortable is True
assert bitrate_col.sort_key == "extra.bitrate_value"
size_col = next(col for col in config.columns if col.key == "size")
assert size_col.sortable is True
assert size_col.sort_key == "size_bytes"
+1 -36
View File
@@ -4,7 +4,7 @@ Tests for AudiobookBay utility functions.
import pytest
from shelfmark.release_sources.audiobookbay.utils import parse_size, sanitize_title
from shelfmark.release_sources.audiobookbay.utils import parse_size
class TestParseSize:
@@ -66,38 +66,3 @@ class TestParseSize:
"""Test parsing with various whitespace."""
assert parse_size(" 1 GB ") == 1024 ** 3
assert parse_size("1.5\tMB") == int(1.5 * (1024 ** 2))
class TestSanitizeTitle:
"""Tests for the sanitize_title function."""
def test_sanitize_title_removes_invalid_chars(self):
"""Test removing invalid filename characters."""
assert sanitize_title("Test<Book>") == "TestBook"
assert sanitize_title("Test:Book") == "TestBook"
assert sanitize_title("Test/Book") == "TestBook"
assert sanitize_title("Test\\Book") == "TestBook"
assert sanitize_title("Test|Book") == "TestBook"
assert sanitize_title("Test?Book") == "TestBook"
assert sanitize_title("Test*Book") == "TestBook"
assert sanitize_title('Test"Book') == "TestBook"
def test_sanitize_title_preserves_valid_chars(self):
"""Test that valid characters are preserved."""
assert sanitize_title("Test Book - Author") == "Test Book - Author"
assert sanitize_title("Test Book (2024)") == "Test Book (2024)"
assert sanitize_title("Test Book [Special]") == "Test Book [Special]"
assert sanitize_title("Test Book's Title") == "Test Book's Title"
def test_sanitize_title_strips_whitespace(self):
"""Test that leading/trailing whitespace is stripped."""
assert sanitize_title(" Test Book ") == "Test Book"
assert sanitize_title("\tTest Book\n") == "Test Book"
def test_sanitize_title_empty(self):
"""Test that empty string returns empty."""
assert sanitize_title("") == ""
def test_sanitize_title_multiple_invalid_chars(self):
"""Test removing multiple invalid characters."""
assert sanitize_title("Test<Book>:Author/Title") == "TestBookAuthorTitle"
+1 -1
View File
@@ -4,7 +4,7 @@ Tests for bencode encoding/decoding in the torrent utilities.
import pytest
from shelfmark.release_sources.prowlarr.clients.torrent_utils import (
from shelfmark.download.clients.torrent_utils import (
bencode_encode as _bencode_encode,
bencode_decode as _bencode_decode,
extract_info_hash_from_torrent as _extract_info_hash_from_torrent,
+1 -1
View File
@@ -4,7 +4,7 @@ Tests for the download client infrastructure.
import pytest
from shelfmark.release_sources.prowlarr.clients import (
from shelfmark.download.clients import (
DownloadStatus,
DownloadState,
DownloadClient,
+1 -1
View File
@@ -18,7 +18,7 @@ import pytest
from shelfmark.core.models import DownloadTask
from shelfmark.release_sources.prowlarr.handler import ProwlarrHandler
from shelfmark.release_sources.prowlarr.clients import (
from shelfmark.download.clients import (
DownloadClient,
DownloadState,
DownloadStatus,
+1 -1
View File
@@ -16,7 +16,7 @@ import pytest
from shelfmark.core.models import DownloadTask
from shelfmark.release_sources.prowlarr.handler import ProwlarrHandler
from shelfmark.release_sources.prowlarr.utils import get_protocol
from shelfmark.release_sources.prowlarr.clients import (
from shelfmark.download.clients import (
DownloadStatus,
DownloadState,
)
+10 -8
View File
@@ -17,7 +17,7 @@ import pytest
from shelfmark.core.config import config
from shelfmark.core.settings_registry import save_config_file
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.download.clients import DownloadStatus
# Test magnet link (Ubuntu ISO - legal, small metadata)
@@ -115,7 +115,7 @@ def _try_get_transmission_client():
"""Try to get a working Transmission client, or None if unavailable."""
_setup_transmission_config()
try:
from shelfmark.release_sources.prowlarr.clients.transmission import TransmissionClient
from shelfmark.download.clients.transmission import TransmissionClient
client = TransmissionClient()
client.test_connection()
return client
@@ -127,7 +127,7 @@ def _try_get_qbittorrent_client():
"""Try to get a working qBittorrent client, or None if unavailable."""
_setup_qbittorrent_config()
try:
from shelfmark.release_sources.prowlarr.clients.qbittorrent import QBittorrentClient
from shelfmark.download.clients.qbittorrent import QBittorrentClient
client = QBittorrentClient()
success, _ = client.test_connection()
if success:
@@ -141,7 +141,7 @@ def _try_get_deluge_client():
"""Try to get a working Deluge client, or None if unavailable."""
_setup_deluge_config()
try:
from shelfmark.release_sources.prowlarr.clients.deluge import DelugeClient
from shelfmark.download.clients.deluge import DelugeClient
client = DelugeClient()
success, _ = client.test_connection()
if success:
@@ -155,10 +155,12 @@ def _try_get_nzbget_client():
"""Try to get a working NZBGet client, or None if unavailable."""
_setup_nzbget_config()
try:
from shelfmark.release_sources.prowlarr.clients.nzbget import NZBGetClient
from shelfmark.download.clients.nzbget import NZBGetClient
client = NZBGetClient()
client.test_connection()
return client
success, _ = client.test_connection()
if success:
return client
return None
except Exception:
return None
@@ -168,7 +170,7 @@ def _try_get_sabnzbd_client():
if not _setup_sabnzbd_config():
return None
try:
from shelfmark.release_sources.prowlarr.clients.sabnzbd import SABnzbdClient
from shelfmark.download.clients.sabnzbd import SABnzbdClient
client = SABnzbdClient()
success, _ = client.test_connection()
if success:
+4 -4
View File
@@ -18,7 +18,7 @@ import pytest
from shelfmark.core.config import config
from shelfmark.core.settings_registry import save_config_file
from shelfmark.release_sources.prowlarr.clients import DownloadStatus, DownloadState
from shelfmark.download.clients import DownloadStatus, DownloadState
# Invalid magnet - valid format but non-existent torrent
@@ -74,7 +74,7 @@ def _setup_deluge_config():
def _try_get_transmission_client():
_setup_transmission_config()
try:
from shelfmark.release_sources.prowlarr.clients.transmission import TransmissionClient
from shelfmark.download.clients.transmission import TransmissionClient
client = TransmissionClient()
client.test_connection()
return client
@@ -85,7 +85,7 @@ def _try_get_transmission_client():
def _try_get_qbittorrent_client():
_setup_qbittorrent_config()
try:
from shelfmark.release_sources.prowlarr.clients.qbittorrent import QBittorrentClient
from shelfmark.download.clients.qbittorrent import QBittorrentClient
client = QBittorrentClient()
success, _ = client.test_connection()
if success:
@@ -98,7 +98,7 @@ def _try_get_qbittorrent_client():
def _try_get_deluge_client():
_setup_deluge_config()
try:
from shelfmark.release_sources.prowlarr.clients.deluge import DelugeClient
from shelfmark.download.clients.deluge import DelugeClient
client = DelugeClient()
success, _ = client.test_connection()
if success:
+1 -1
View File
@@ -39,7 +39,7 @@ def _is_transmission_available():
"""Check if Transmission is available."""
_setup_transmission_config()
try:
from shelfmark.release_sources.prowlarr.clients.transmission import TransmissionClient
from shelfmark.download.clients.transmission import TransmissionClient
client = TransmissionClient()
success, _ = client.test_connection()
return success
+45 -45
View File
@@ -8,7 +8,7 @@ without requiring a running NZBGet instance.
from unittest.mock import MagicMock, patch
import pytest
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.download.clients import DownloadStatus
class TestNZBGetClientIsConfigured:
@@ -21,11 +21,11 @@ class TestNZBGetClientIsConfigured:
"NZBGET_URL": "http://localhost:6789",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -38,11 +38,11 @@ class TestNZBGetClientIsConfigured:
"NZBGET_URL": "http://localhost:6789",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -55,11 +55,11 @@ class TestNZBGetClientIsConfigured:
"NZBGET_URL": "",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -78,7 +78,7 @@ class TestNZBGetClientTestConnection:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -86,10 +86,10 @@ class TestNZBGetClientTestConnection:
mock_response.json.return_value = {"result": {"Version": "21.1"}}
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
return_value=mock_response,
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -110,15 +110,15 @@ class TestNZBGetClientTestConnection:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
side_effect=requests.exceptions.ConnectionError("Connection refused"),
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -139,15 +139,15 @@ class TestNZBGetClientTestConnection:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
side_effect=requests.exceptions.Timeout("Timeout"),
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -170,7 +170,7 @@ class TestNZBGetClientRPCCall:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -178,10 +178,10 @@ class TestNZBGetClientRPCCall:
mock_response.json.return_value = {"result": "test_result"}
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
return_value=mock_response,
) as mock_post:
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -202,7 +202,7 @@ class TestNZBGetClientRPCCall:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -210,10 +210,10 @@ class TestNZBGetClientRPCCall:
mock_response.json.return_value = {"error": {"message": "Invalid method"}}
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
return_value=mock_response,
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -236,7 +236,7 @@ class TestNZBGetClientGetStatus:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -256,7 +256,7 @@ class TestNZBGetClientGetStatus:
]
return []
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -285,7 +285,7 @@ class TestNZBGetClientGetStatus:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -302,7 +302,7 @@ class TestNZBGetClientGetStatus:
]
return []
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -330,7 +330,7 @@ class TestNZBGetClientGetStatus:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -347,7 +347,7 @@ class TestNZBGetClientGetStatus:
]
return []
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -373,14 +373,14 @@ class TestNZBGetClientGetStatus:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
def mock_rpc_call(method, params=None):
return [] # Empty queue and history
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -406,7 +406,7 @@ class TestNZBGetClientGetStatus:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -426,7 +426,7 @@ class TestNZBGetClientGetStatus:
]
return []
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -455,7 +455,7 @@ class TestNZBGetClientAddDownload:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -468,13 +468,13 @@ class TestNZBGetClientAddDownload:
mock_post_response.json.return_value = {"result": 456}
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.get",
"shelfmark.download.clients.nzbget.requests.get",
return_value=mock_get_response,
), patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.post",
"shelfmark.download.clients.nzbget.requests.post",
return_value=mock_post_response,
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -497,15 +497,15 @@ class TestNZBGetClientAddDownload:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
with patch(
"shelfmark.release_sources.prowlarr.clients.nzbget.requests.get",
"shelfmark.download.clients.nzbget.requests.get",
side_effect=requests.RequestException("Failed to fetch"),
):
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -528,7 +528,7 @@ class TestNZBGetClientRemove:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -537,7 +537,7 @@ class TestNZBGetClientRemove:
return True
return None
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -562,7 +562,7 @@ class TestNZBGetClientRemove:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -574,7 +574,7 @@ class TestNZBGetClientRemove:
return True
return None
from shelfmark.release_sources.prowlarr.clients.nzbget import (
from shelfmark.download.clients.nzbget import (
NZBGetClient,
)
@@ -603,7 +603,7 @@ class TestNZBGetClientRemove:
"NZBGET_CATEGORY": "Books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.nzbget.config.get",
"shelfmark.download.clients.nzbget.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -616,7 +616,7 @@ class TestNZBGetClientRemove:
return params is not None and params[0] == "HistoryDelete"
return None
from shelfmark.release_sources.prowlarr.clients.nzbget import NZBGetClient
from shelfmark.download.clients.nzbget import NZBGetClient
with patch.object(NZBGetClient, "__init__", lambda x: None):
client = NZBGetClient()
+59 -59
View File
@@ -9,8 +9,8 @@ import sys
from unittest.mock import MagicMock, patch
import pytest
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.release_sources.prowlarr.clients.torrent_utils import TorrentInfo
from shelfmark.download.clients import DownloadStatus
from shelfmark.download.clients.torrent_utils import TorrentInfo
class MockTorrent:
@@ -66,11 +66,11 @@ class TestQBittorrentClientIsConfigured:
"QBITTORRENT_URL": "http://localhost:8080",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.qbittorrent import (
from shelfmark.download.clients.qbittorrent import (
QBittorrentClient,
)
@@ -83,11 +83,11 @@ class TestQBittorrentClientIsConfigured:
"QBITTORRENT_URL": "http://localhost:8080",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.qbittorrent import (
from shelfmark.download.clients.qbittorrent import (
QBittorrentClient,
)
@@ -100,11 +100,11 @@ class TestQBittorrentClientIsConfigured:
"QBITTORRENT_URL": "",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.qbittorrent import (
from shelfmark.download.clients.qbittorrent import (
QBittorrentClient,
)
@@ -123,7 +123,7 @@ class TestQBittorrentClientTestConnection:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -135,7 +135,7 @@ class TestQBittorrentClientTestConnection:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
# Need to reimport after patching
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -153,7 +153,7 @@ class TestQBittorrentClientTestConnection:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -163,7 +163,7 @@ class TestQBittorrentClientTestConnection:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -185,7 +185,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -197,7 +197,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -218,7 +218,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -234,7 +234,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -253,7 +253,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -272,7 +272,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -290,7 +290,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -335,7 +335,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -352,7 +352,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -367,7 +367,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -386,7 +386,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -398,7 +398,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -417,7 +417,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -429,7 +429,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -446,7 +446,7 @@ class TestQBittorrentClientGetStatus:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -458,7 +458,7 @@ class TestQBittorrentClientGetStatus:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -479,7 +479,7 @@ class TestQBittorrentClientAddDownload:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -493,7 +493,7 @@ class TestQBittorrentClientAddDownload:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -512,7 +512,7 @@ class TestQBittorrentClientAddDownload:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -526,11 +526,11 @@ class TestQBittorrentClientAddDownload:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
with patch(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.extract_torrent_info",
"shelfmark.download.clients.qbittorrent.extract_torrent_info",
autospec=True,
) as mock_extract:
mock_extract.return_value = TorrentInfo(
@@ -562,7 +562,7 @@ class TestQBittorrentClientAddDownload:
"QBITTORRENT_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -578,7 +578,7 @@ class TestQBittorrentClientAddDownload:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -600,7 +600,7 @@ class TestQBittorrentClientRemove:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -609,7 +609,7 @@ class TestQBittorrentClientRemove:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -629,7 +629,7 @@ class TestQBittorrentClientRemove:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -639,7 +639,7 @@ class TestQBittorrentClientRemove:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -659,7 +659,7 @@ class TestQBittorrentClientGetDownloadPath:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -673,7 +673,7 @@ class TestQBittorrentClientGetDownloadPath:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -690,7 +690,7 @@ class TestQBittorrentClientGetDownloadPath:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -708,7 +708,7 @@ class TestQBittorrentClientGetDownloadPath:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -725,7 +725,7 @@ class TestQBittorrentClientGetDownloadPath:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -766,7 +766,7 @@ class TestQBittorrentClientGetDownloadPath:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -782,7 +782,7 @@ class TestQBittorrentClientGetDownloadPath:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -825,7 +825,7 @@ class TestQBittorrentClientGetDownloadPath:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -846,7 +846,7 @@ class TestQBittorrentClientFindExisting:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -862,7 +862,7 @@ class TestQBittorrentClientFindExisting:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -883,7 +883,7 @@ class TestQBittorrentClientFindExisting:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -898,7 +898,7 @@ class TestQBittorrentClientFindExisting:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -916,7 +916,7 @@ class TestQBittorrentClientFindExisting:
"QBITTORRENT_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.qbittorrent.config.get",
"shelfmark.download.clients.qbittorrent.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -925,7 +925,7 @@ class TestQBittorrentClientFindExisting:
with patch.dict('sys.modules', {'qbittorrentapi': MagicMock(Client=mock_client_class)}):
import importlib
import shelfmark.release_sources.prowlarr.clients.qbittorrent as qb_module
import shelfmark.download.clients.qbittorrent as qb_module
importlib.reload(qb_module)
client = qb_module.QBittorrentClient()
@@ -938,34 +938,34 @@ class TestHashesMatch:
"""Tests for _hashes_match() - Amarr compatibility."""
def test_identical_hashes_match(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
assert _hashes_match("abc123", "abc123") is True
assert _hashes_match("ABC123", "abc123") is True
def test_different_hashes_dont_match(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
assert _hashes_match("abc123", "def456") is False
def test_amarr_padded_hash_matches_ed2k_hash(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
ed2k_hash = "0320c47b3baa01f8d5f42cd7c05ce28d" # 32 chars
padded_hash = "0320c47b3baa01f8d5f42cd7c05ce28d00000000" # 40 chars
assert _hashes_match(padded_hash, ed2k_hash) is True
assert _hashes_match(ed2k_hash, padded_hash) is True
def test_non_zero_padded_40_char_hash_doesnt_match(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
bittorrent_hash = "3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0"
partial_hash = "3b245504cf5f11bbdbe1201cea6a6bf4"
assert _hashes_match(bittorrent_hash, partial_hash) is False
def test_matching_is_case_insensitive(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
ed2k_hash = "0320C47B3BAA01F8D5F42CD7C05CE28D"
padded_hash = "0320c47b3baa01f8d5f42cd7c05ce28d00000000"
assert _hashes_match(padded_hash, ed2k_hash) is True
def test_wrong_length_hashes_dont_match(self):
from shelfmark.release_sources.prowlarr.clients.qbittorrent import _hashes_match
from shelfmark.download.clients.qbittorrent import _hashes_match
assert _hashes_match("a" * 40, "b" * 30) is False
assert _hashes_match("a" * 38, "b" * 32) is False
+1 -1
View File
@@ -9,7 +9,7 @@ from threading import Event
from unittest.mock import MagicMock, patch
from shelfmark.core.models import DownloadTask
from shelfmark.release_sources.prowlarr.clients import DownloadState, DownloadStatus
from shelfmark.download.clients import DownloadState, DownloadStatus
from shelfmark.release_sources.prowlarr.handler import ProwlarrHandler
+70 -70
View File
@@ -9,7 +9,7 @@ from unittest.mock import MagicMock, patch
import pytest
import sys
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.download.clients import DownloadStatus
def make_config_getter(values):
@@ -38,11 +38,11 @@ class TestRTorrentClientIsConfigured:
"RTORRENT_URL": "http://localhost:8080/RPC2",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.rtorrent import RTorrentClient
from shelfmark.download.clients.rtorrent import RTorrentClient
assert RTorrentClient.is_configured() is True
@@ -53,11 +53,11 @@ class TestRTorrentClientIsConfigured:
"RTORRENT_URL": "http://localhost:8080/RPC2",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.rtorrent import RTorrentClient
from shelfmark.download.clients.rtorrent import RTorrentClient
assert RTorrentClient.is_configured() is False
@@ -68,11 +68,11 @@ class TestRTorrentClientIsConfigured:
"RTORRENT_URL": "",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.rtorrent import RTorrentClient
from shelfmark.download.clients.rtorrent import RTorrentClient
assert RTorrentClient.is_configured() is False
@@ -90,7 +90,7 @@ class TestRTorrentClientTestConnection:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -101,10 +101,10 @@ class TestRTorrentClientTestConnection:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -124,7 +124,7 @@ class TestRTorrentClientTestConnection:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -135,10 +135,10 @@ class TestRTorrentClientTestConnection:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -158,7 +158,7 @@ class TestRTorrentClientTestConnection:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -169,10 +169,10 @@ class TestRTorrentClientTestConnection:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -196,7 +196,7 @@ class TestRTorrentClientAddDownload:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -213,15 +213,15 @@ class TestRTorrentClientAddDownload:
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
with patch(
"shelfmark.release_sources.prowlarr.clients.torrent_utils.extract_torrent_info",
"shelfmark.download.clients.torrent_utils.extract_torrent_info",
return_value=mock_torrent_info,
):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules[
"shelfmark.release_sources.prowlarr.clients.rtorrent"
"shelfmark.download.clients.rtorrent"
]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -247,7 +247,7 @@ class TestRTorrentClientAddDownload:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -264,15 +264,15 @@ class TestRTorrentClientAddDownload:
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
with patch(
"shelfmark.release_sources.prowlarr.clients.torrent_utils.extract_torrent_info",
"shelfmark.download.clients.torrent_utils.extract_torrent_info",
return_value=mock_torrent_info,
):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules[
"shelfmark.release_sources.prowlarr.clients.rtorrent"
"shelfmark.download.clients.rtorrent"
]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -293,7 +293,7 @@ class TestRTorrentClientAddDownload:
"RTORRENT_URL": "http://localhost:8080/RPC2",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -309,15 +309,15 @@ class TestRTorrentClientAddDownload:
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
with patch(
"shelfmark.release_sources.prowlarr.clients.rtorrent.extract_torrent_info",
"shelfmark.download.clients.rtorrent.extract_torrent_info",
return_value=mock_torrent_info,
):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules[
"shelfmark.release_sources.prowlarr.clients.rtorrent"
"shelfmark.download.clients.rtorrent"
]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -341,7 +341,7 @@ class TestRTorrentClientGetStatus:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -363,10 +363,10 @@ class TestRTorrentClientGetStatus:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -388,7 +388,7 @@ class TestRTorrentClientGetStatus:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -413,10 +413,10 @@ class TestRTorrentClientGetStatus:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -439,7 +439,7 @@ class TestRTorrentClientGetStatus:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -450,10 +450,10 @@ class TestRTorrentClientGetStatus:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -473,7 +473,7 @@ class TestRTorrentClientGetStatus:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -495,10 +495,10 @@ class TestRTorrentClientGetStatus:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -522,7 +522,7 @@ class TestRTorrentClientRemove:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -532,10 +532,10 @@ class TestRTorrentClientRemove:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -556,7 +556,7 @@ class TestRTorrentClientRemove:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -566,10 +566,10 @@ class TestRTorrentClientRemove:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -590,7 +590,7 @@ class TestRTorrentClientRemove:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -601,10 +601,10 @@ class TestRTorrentClientRemove:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -627,7 +627,7 @@ class TestRTorrentClientGetDownloadPath:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -638,10 +638,10 @@ class TestRTorrentClientGetDownloadPath:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
@@ -660,7 +660,7 @@ class TestRTorrentClientGetDownloadPath:
"RTORRENT_LABEL": "cwabd",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.rtorrent.config.get",
"shelfmark.download.clients.rtorrent.config.get",
make_config_getter(config_values),
)
@@ -671,10 +671,10 @@ class TestRTorrentClientGetDownloadPath:
mock_xmlrpc.ServerProxy.return_value = mock_rpc
with patch.dict("sys.modules", {"xmlrpc.client": mock_xmlrpc}):
if "shelfmark.release_sources.prowlarr.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.rtorrent"]
if "shelfmark.download.clients.rtorrent" in sys.modules:
del sys.modules["shelfmark.download.clients.rtorrent"]
from shelfmark.release_sources.prowlarr.clients.rtorrent import (
from shelfmark.download.clients.rtorrent import (
RTorrentClient,
)
+47 -47
View File
@@ -8,7 +8,7 @@ without requiring a running SABnzbd instance.
from unittest.mock import MagicMock, patch
import pytest
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.download.clients import DownloadStatus
class TestSABnzbdClientIsConfigured:
@@ -22,11 +22,11 @@ class TestSABnzbdClientIsConfigured:
"SABNZBD_API_KEY": "abc123",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -40,11 +40,11 @@ class TestSABnzbdClientIsConfigured:
"SABNZBD_API_KEY": "abc123",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -58,11 +58,11 @@ class TestSABnzbdClientIsConfigured:
"SABNZBD_API_KEY": "abc123",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -76,11 +76,11 @@ class TestSABnzbdClientIsConfigured:
"SABNZBD_API_KEY": "",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -98,7 +98,7 @@ class TestSABnzbdClientTestConnection:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -106,10 +106,10 @@ class TestSABnzbdClientTestConnection:
mock_response.json.return_value = {"version": "4.2.1"}
with patch(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.requests.get",
"shelfmark.download.clients.sabnzbd.requests.get",
return_value=mock_response,
):
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -129,15 +129,15 @@ class TestSABnzbdClientTestConnection:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
with patch(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.requests.get",
"shelfmark.download.clients.sabnzbd.requests.get",
side_effect=requests.exceptions.ConnectionError("Connection refused"),
):
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -159,7 +159,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -181,7 +181,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -208,7 +208,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -230,7 +230,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -260,7 +260,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -281,7 +281,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -307,7 +307,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -328,7 +328,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -352,7 +352,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -363,7 +363,7 @@ class TestSABnzbdClientGetStatus:
return {"history": {"slots": []}}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -387,7 +387,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -408,7 +408,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -431,7 +431,7 @@ class TestSABnzbdClientGetStatus:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -452,7 +452,7 @@ class TestSABnzbdClientGetStatus:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -479,11 +479,11 @@ class TestSABnzbdClientAddDownload:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -509,11 +509,11 @@ class TestSABnzbdClientAddDownload:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -544,11 +544,11 @@ class TestSABnzbdClientAddDownload:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -580,7 +580,7 @@ class TestSABnzbdClientRemove:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -589,7 +589,7 @@ class TestSABnzbdClientRemove:
return {"status": True}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -612,7 +612,7 @@ class TestSABnzbdClientRemove:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -627,7 +627,7 @@ class TestSABnzbdClientRemove:
return {"status": True} # Found in history
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -655,7 +655,7 @@ class TestSABnzbdClientFindExisting:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -678,7 +678,7 @@ class TestSABnzbdClientFindExisting:
}
return {"history": {"slots": []}}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -703,7 +703,7 @@ class TestSABnzbdClientFindExisting:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -726,7 +726,7 @@ class TestSABnzbdClientFindExisting:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -751,7 +751,7 @@ class TestSABnzbdClientFindExisting:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -762,7 +762,7 @@ class TestSABnzbdClientFindExisting:
return {"history": {"slots": []}}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
@@ -789,7 +789,7 @@ class TestSABnzbdClientFindExisting:
"SABNZBD_CATEGORY": "books",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.sabnzbd.config.get",
"shelfmark.download.clients.sabnzbd.config.get",
lambda key, default="": config_values.get(key, default),
)
@@ -826,7 +826,7 @@ class TestSABnzbdClientFindExisting:
}
return {}
from shelfmark.release_sources.prowlarr.clients.sabnzbd import (
from shelfmark.download.clients.sabnzbd import (
SABnzbdClient,
)
+1 -1
View File
@@ -13,7 +13,7 @@ import hashlib
import pytest
from shelfmark.release_sources.prowlarr.clients.torrent_utils import (
from shelfmark.download.clients.torrent_utils import (
parse_transmission_url,
bencode_decode,
bencode_encode,
+63 -63
View File
@@ -10,7 +10,7 @@ from datetime import timedelta
import pytest
import sys
from shelfmark.release_sources.prowlarr.clients import DownloadStatus
from shelfmark.download.clients import DownloadStatus
class MockTorrentStatus:
@@ -76,11 +76,11 @@ class TestTransmissionClientIsConfigured:
"TRANSMISSION_URL": "http://localhost:9091",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -93,11 +93,11 @@ class TestTransmissionClientIsConfigured:
"TRANSMISSION_URL": "http://localhost:9091",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -110,11 +110,11 @@ class TestTransmissionClientIsConfigured:
"TRANSMISSION_URL": "",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -133,7 +133,7 @@ class TestTransmissionClientTestConnection:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -144,10 +144,10 @@ class TestTransmissionClientTestConnection:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -163,7 +163,7 @@ class TestTransmissionClientTestConnection:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -175,10 +175,10 @@ class TestTransmissionClientTestConnection:
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
# Force reimport to use mock
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -197,7 +197,7 @@ class TestTransmissionClientTestConnection:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -208,10 +208,10 @@ class TestTransmissionClientTestConnection:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -234,7 +234,7 @@ class TestTransmissionClientGetStatus:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -246,10 +246,10 @@ class TestTransmissionClientGetStatus:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -270,7 +270,7 @@ class TestTransmissionClientGetStatus:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -286,10 +286,10 @@ class TestTransmissionClientGetStatus:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -309,7 +309,7 @@ class TestTransmissionClientGetStatus:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -320,10 +320,10 @@ class TestTransmissionClientGetStatus:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -342,7 +342,7 @@ class TestTransmissionClientGetStatus:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -354,10 +354,10 @@ class TestTransmissionClientGetStatus:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -375,7 +375,7 @@ class TestTransmissionClientGetStatus:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -387,10 +387,10 @@ class TestTransmissionClientGetStatus:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -412,7 +412,7 @@ class TestTransmissionClientAddDownload:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -424,10 +424,10 @@ class TestTransmissionClientAddDownload:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -447,7 +447,7 @@ class TestTransmissionClientAddDownload:
"TRANSMISSION_CATEGORY": "mybooks",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -459,10 +459,10 @@ class TestTransmissionClientAddDownload:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -487,7 +487,7 @@ class TestTransmissionClientRemove:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -497,10 +497,10 @@ class TestTransmissionClientRemove:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -521,7 +521,7 @@ class TestTransmissionClientRemove:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -532,10 +532,10 @@ class TestTransmissionClientRemove:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -557,7 +557,7 @@ class TestTransmissionClientFindExisting:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -573,10 +573,10 @@ class TestTransmissionClientFindExisting:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)
@@ -598,7 +598,7 @@ class TestTransmissionClientFindExisting:
"TRANSMISSION_CATEGORY": "test",
}
monkeypatch.setattr(
"shelfmark.release_sources.prowlarr.clients.transmission.config.get",
"shelfmark.download.clients.transmission.config.get",
make_config_getter(config_values),
)
@@ -609,10 +609,10 @@ class TestTransmissionClientFindExisting:
mock_transmission_rpc.Client.return_value = mock_client_instance
with patch.dict("sys.modules", {"transmission_rpc": mock_transmission_rpc}):
if "shelfmark.release_sources.prowlarr.clients.transmission" in sys.modules:
del sys.modules["shelfmark.release_sources.prowlarr.clients.transmission"]
if "shelfmark.download.clients.transmission" in sys.modules:
del sys.modules["shelfmark.download.clients.transmission"]
from shelfmark.release_sources.prowlarr.clients.transmission import (
from shelfmark.download.clients.transmission import (
TransmissionClient,
)