test: add local 2x2 route topology

This commit is contained in:
2026-07-23 03:14:16 +00:00
parent 10e803eaee
commit a66269cb69
27 changed files with 775 additions and 7 deletions
+26 -2
View File
@@ -13,8 +13,9 @@ from archive_clients.qbittorrent import QBittorrentReader
class _Response:
def __init__(self, value: bytes):
def __init__(self, value: bytes, status: int = 200):
self.value = io.BytesIO(value)
self.status = status
def read(self, size=-1):
return self.value.read(size)
@@ -33,7 +34,10 @@ class _Opener:
def open(self, call, timeout):
self.calls.append(call)
return _Response(next(self.values))
response = next(self.values)
if isinstance(response, tuple):
return _Response(*response)
return _Response(response)
class QBittorrentReaderTests(unittest.TestCase):
@@ -71,6 +75,26 @@ class QBittorrentReaderTests(unittest.TestCase):
self.assertEqual(resource.summary.resource_id.info_hash_v1_hex, torrent_hash)
self.assertIn("hashes=", opener.calls[1])
def test_current_empty_204_login_is_accepted(self):
responses = [(b"", 204), b"[]"]
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
password = root / "password"
password.write_text("secret", encoding="utf-8")
os.chmod(password, 0o600)
config = ServiceConfig(
"http://qb", PurePosixPath("/downloads"), root,
username="admin", password_file=password,
)
opener = _Opener(responses)
with patch(
"archive_clients.qbittorrent.request.build_opener",
return_value=opener,
):
resources = QBittorrentReader(config).list_resources()
self.assertEqual(resources, [])
self.assertEqual(len(opener.calls), 2)
if __name__ == "__main__":
unittest.main()