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
@@ -11,8 +11,9 @@ from archive_control.v1 import common_pb2
class _Response:
def __init__(self, value: str):
def __init__(self, value: str, status: int = 200):
self._source = io.BytesIO(value.encode("utf-8"))
self.status = status
def read(self, size: int = -1) -> bytes:
return self._source.read(size)
@@ -31,7 +32,10 @@ class _Opener:
def open(self, call, timeout):
self.requests.append((call, timeout))
return _Response(next(self.responses))
response = next(self.responses)
if isinstance(response, tuple):
return _Response(*response)
return _Response(response)
class ServiceProbeTests(unittest.TestCase):
@@ -57,6 +61,26 @@ class ServiceProbeTests(unittest.TestCase):
self.assertEqual(result.libtorrent_version, "2.0.11")
self.assertIn(b"password=private", opener.requests[0][0].data)
def test_qbittorrent_accepts_current_empty_204_login(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
password = self._secret(root, "password", "private")
config = ServiceConfig(
"http://qb:8080", PurePosixPath("/downloads"), root,
username="admin", password_file=password,
)
opener = _Opener([
("", 204), "v5.2.3", "2.11.4",
'{"libtorrent":"2.0.13"}',
])
with patch(
"archive_clients.services.request.build_opener",
return_value=opener,
):
result = probe_qbittorrent(config)
self.assertEqual(result.state, common_pb2.HEALTH_STATE_HEALTHY)
self.assertEqual(result.version, "v5.2.3")
def test_syncthing_identity_is_normalized(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)