File: test_radios.py

package info (click to toggle)
python-radios 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: python: 454; makefile: 7; sh: 5
file content (26 lines) | stat: -rw-r--r-- 815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Asynchronous Python client for the Radio Browser API."""

# pylint: disable=protected-access
import aiohttp
from aresponses import ResponsesMockServer

from radios.radio_browser import RadioBrowser


async def test_json_request(aresponses: ResponsesMockServer) -> None:
    """Test JSON response is handled correctly."""
    aresponses.add(
        "example.com",
        "/json/test",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text='{"status": "ok"}',
        ),
    )
    async with aiohttp.ClientSession() as session:
        radio = RadioBrowser(session=session, user_agent="Test")
        radio._host = "example.com"
        response = await radio._request("test")
        assert response == '{"status": "ok"}'