import hashlib from lyra_worker.adapters._streamrip import StreamripClient, _hashed_password def test_hashed_password_is_md5_hex(): # streamrip's Qobuz email/password login expects the MD5 hex digest, not plaintext. assert _hashed_password("hunter2") == hashlib.md5(b"hunter2").hexdigest() assert len(_hashed_password("anything")) == 32 assert all(c in "0123456789abcdef" for c in _hashed_password("anything")) def test_is_configured(): # email + password assert StreamripClient({"qobuz.email": "a@b.c", "qobuz.password": "p"}).is_configured() is True # user_id + auth token (the reliable path) assert StreamripClient({"qobuz.user_id": "123", "qobuz.auth_token": "tok"}).is_configured() is True # nothing configured assert StreamripClient({}).is_configured() is False # partial (token without user_id, password without email) -> not configured assert StreamripClient({"qobuz.auth_token": "tok"}).is_configured() is False assert StreamripClient({"qobuz.password": "p"}).is_configured() is False