|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import json |
5 | 6 | from typing import TYPE_CHECKING |
6 | 7 |
|
7 | 8 | from aiohttp.hdrs import METH_PUT |
| 9 | +from awesomeversion import AwesomeVersion |
8 | 10 | import pytest |
9 | 11 |
|
10 | 12 | from go2rtc_client.models import WebRTCSdpOffer |
11 | | -from go2rtc_client.rest import _StreamClient, _WebRTCClient |
| 13 | +from go2rtc_client.rest import _ApplicationClient, _StreamClient, _WebRTCClient |
12 | 14 | from tests import load_fixture |
13 | 15 |
|
14 | 16 | from . import URL |
|
20 | 22 | from go2rtc_client import Go2RtcRestClient |
21 | 23 |
|
22 | 24 |
|
| 25 | +async def test_application_info( |
| 26 | + responses: aioresponses, |
| 27 | + rest_client: Go2RtcRestClient, |
| 28 | + snapshot: SnapshotAssertion, |
| 29 | +) -> None: |
| 30 | + """Test webrtc offer.""" |
| 31 | + responses.get( |
| 32 | + f"{URL}{_ApplicationClient.PATH}", |
| 33 | + status=200, |
| 34 | + body=load_fixture("application_info_answer.json"), |
| 35 | + ) |
| 36 | + resp = await rest_client.application.get_info() |
| 37 | + assert isinstance(resp.version, AwesomeVersion) |
| 38 | + assert resp == snapshot |
| 39 | + assert resp.to_dict() == snapshot |
| 40 | + |
| 41 | + |
23 | 42 | @pytest.mark.parametrize( |
24 | 43 | "filename", |
25 | 44 | [ |
@@ -69,6 +88,34 @@ async def test_streams_add( |
69 | 88 | responses.assert_called_once_with(url, method=METH_PUT, params=params) |
70 | 89 |
|
71 | 90 |
|
| 91 | +@pytest.mark.parametrize( |
| 92 | + ("server_version", "expected_result"), |
| 93 | + [ |
| 94 | + ("0.0.0", False), |
| 95 | + ("1.9.3", False), |
| 96 | + ("1.9.4", True), |
| 97 | + ("1.9.5", False), |
| 98 | + ("2.0.0", False), |
| 99 | + ("BLAH", False), |
| 100 | + ], |
| 101 | +) |
| 102 | +async def test_version_supported( |
| 103 | + responses: aioresponses, |
| 104 | + rest_client: Go2RtcRestClient, |
| 105 | + server_version: str, |
| 106 | + expected_result: bool, |
| 107 | +) -> None: |
| 108 | + """Test webrtc offer.""" |
| 109 | + payload = json.loads(load_fixture("application_info_answer.json")) |
| 110 | + payload["version"] = server_version |
| 111 | + responses.get( |
| 112 | + f"{URL}{_ApplicationClient.PATH}", |
| 113 | + status=200, |
| 114 | + payload=payload, |
| 115 | + ) |
| 116 | + assert await rest_client.validate_server_version() == expected_result |
| 117 | + |
| 118 | + |
72 | 119 | async def test_webrtc_offer( |
73 | 120 | responses: aioresponses, |
74 | 121 | rest_client: Go2RtcRestClient, |
|
0 commit comments