update
Some checks failed
Tests / test (ubuntu-latest, 3.10) (push) Successful in 44s
Tests / test (ubuntu-latest, 3.8) (push) Failing after 4m3s
Tests / test (ubuntu-latest, 3.9) (push) Successful in 14m4s
Tests / test (macos-latest, 3.10) (push) Has been cancelled
Tests / test (macos-latest, 3.8) (push) Has been cancelled
Tests / test (macos-latest, 3.9) (push) Has been cancelled
Tests / test (windows-latest, 3.10) (push) Has been cancelled
Tests / test (windows-latest, 3.8) (push) Has been cancelled
Tests / test (windows-latest, 3.9) (push) Has been cancelled

This commit is contained in:
2025-03-13 11:20:16 -07:00
parent 48ef9a8e71
commit 58e8d92bc3
4 changed files with 13 additions and 76 deletions

View File

@@ -96,16 +96,9 @@ class TestJimakuDownloader:
# Make sure the response object has a working raise_for_status method
mock_requests["response"].raise_for_status = MagicMock()
# Test with special characters in the title
result = downloader.query_anilist(
"KonoSuba Gods blessing on this wonderful world!! (2016)", season=3
)
assert result == 123456
# Patch requests.post directly to use our mock
with patch(
"jimaku_dl.downloader.requests_post", return_value=mock_requests["response"]
):
with patch("jimaku_dl.downloader.requests_post", return_value=mock_requests["response"]):
# Test the function with title and season
result = downloader.query_anilist("Test Anime", season=1)
assert result == 123456
@@ -159,9 +152,7 @@ class TestJimakuDownloader:
mock_requests["response"].raise_for_status = MagicMock()
# Patch requests.post directly to use our mock
with patch(
"jimaku_dl.downloader.requests_post", return_value=mock_requests["response"]
):
with patch("jimaku_dl.downloader.requests_post", return_value=mock_requests["response"]):
# Test the function with title and season - should work even without API token
result = downloader.query_anilist("Test Anime", season=1)
assert result == 123456
@@ -324,18 +315,16 @@ class TestJimakuDownloader:
mock_requests["response"].json.side_effect = None
mock_requests["response"].json.return_value = mock_jimaku_entries_response
mock_requests["get"].return_value = mock_requests["response"]
# Make sure the response object has a working raise_for_status method
mock_requests["response"].raise_for_status = MagicMock()
# Patch the requests.get function directly to use our mock
with patch(
"jimaku_dl.downloader.requests_get", return_value=mock_requests["response"]
):
with patch("jimaku_dl.downloader.requests_get", return_value=mock_requests["response"]):
# Call the function and check the result
result = downloader.query_jimaku_entries(123456)
assert result == mock_jimaku_entries_response
# We won't assert on mock_requests["get"] here since it's not reliable
# due to the patching approach
@@ -346,24 +335,22 @@ class TestJimakuDownloader:
# Set the mock response
mock_requests["response"].json.side_effect = None
mock_requests["response"].json.return_value = mock_jimaku_files_response
# Create a direct mock for requests_get to verify it's called correctly
mock_get = MagicMock(return_value=mock_requests["response"])
# Patch the requests_get function directly
with patch("jimaku_dl.downloader.requests_get", mock_get):
# Call the function and check the result
result = downloader.get_entry_files(1)
assert result == mock_jimaku_files_response
# Verify proper headers were set in the API call
mock_get.assert_called_once()
url = mock_get.call_args[0][0]
assert "entries/1/files" in url
headers = mock_get.call_args[1].get("headers", {})
assert (
headers.get("Authorization") == "test_token"
) # Changed from 'Bearer test_token'
headers = mock_get.call_args[1].get('headers', {})
assert headers.get('Authorization') == 'test_token' # Changed from 'Bearer test_token'
def test_get_entry_files_no_token(self, monkeypatch):
"""Test getting entry files without API token."""