Skip to content

Commit 20fb908

Browse files
Bump aioresponses from 0.7.7 to 0.7.8 (#1040)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Stefan Agner <stefan@agner.ch>
1 parent edcba75 commit 20fb908

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ server = [
4343
"home-assistant-chip-core==2024.11.4",
4444
]
4545
test = [
46-
"aioresponses==0.7.7",
46+
"aioresponses==0.7.8",
4747
"codespell==2.3.0",
4848
"isort==5.13.2",
4949
"mypy==1.14.1",

tests/server/ota/test_dcl.py

+25-22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from aioresponses import aioresponses
99
import pytest
1010

11+
from matter_server.server.helpers import DCL_PRODUCTION_URL
1112
from matter_server.server.ota.dcl import check_for_update
1213

1314

@@ -24,22 +25,31 @@ def mock_aioresponse():
2425
yield m
2526

2627

28+
def mock_dcl_version(
29+
aioresponse, vid: int, pid: int, version: int | None = None, suffix: str = ""
30+
) -> dict:
31+
"""Test."""
32+
if version:
33+
data = _load_fixture(f"{vid}-{pid}-{version}{suffix}.json")
34+
url = DCL_PRODUCTION_URL + f"/dcl/model/versions/{vid}/{pid}/{version}"
35+
else:
36+
data = _load_fixture(f"{vid}-{pid}{suffix}.json")
37+
url = DCL_PRODUCTION_URL + f"/dcl/model/versions/{vid}/{pid}"
38+
aioresponse.get(url=url, status=200, payload=data)
39+
return data
40+
41+
2742
@pytest.fixture(name="get_software_versions", autouse=True)
2843
def _mock_get_software_versions(aioresponse) -> None:
2944
"""Mock the _get_software_versions function."""
30-
data = _load_fixture("4447-8194.json")
31-
aioresponse.get(url="/dcl/model/versions/4447/8194", status=200, payload=data)
32-
aioresponse.get(
33-
url="/dcl/model/versions/4447/8194/1000",
34-
payload=_load_fixture("4447-8194-1000.json"),
35-
)
45+
mock_dcl_version(aioresponse, 4447, 8194)
46+
mock_dcl_version(aioresponse, 4447, 8194, 1000)
3647

3748

3849
async def test_check_updates(aioresponse):
3950
"""Test the case where the latest software version is applicable."""
4051
# Call the function with a current software version of 1000
41-
data = _load_fixture("4447-8194-1011-valid.json")
42-
aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
52+
data = mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
4353
result = await check_for_update(MagicMock(), 4447, 8194, 1000)
4454

4555
assert result == data["modelVersion"]
@@ -48,17 +58,15 @@ async def test_check_updates(aioresponse):
4858
async def test_check_updates_not_applicable(aioresponse):
4959
"""Test the case where the latest software version is not applicable."""
5060
# Call the function with a current software version of 2000
51-
data = _load_fixture("4447-8194-1011-valid.json")
52-
aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
61+
mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
5362
result = await check_for_update(MagicMock(), 4447, 8194, 2000)
5463

5564
assert result is None
5665

5766

5867
async def test_check_updates_not_applicable_not_valid(aioresponse):
5968
"""Test the case where the latest software version is not valid."""
60-
data = _load_fixture("4447-8194-1011-invalid.json")
61-
aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
69+
mock_dcl_version(aioresponse, 4447, 8194, 1011, "-invalid")
6270
result = await check_for_update(MagicMock(), 4447, 8194, 1000)
6371

6472
assert result is None
@@ -67,8 +75,7 @@ async def test_check_updates_not_applicable_not_valid(aioresponse):
6775
async def test_check_updates_specific_version(aioresponse):
6876
"""Test the case to get a specific version."""
6977
# Call the function with a current software version of 1000 and request 1011 as update
70-
data = _load_fixture("4447-8194-1011-valid.json")
71-
aioresponse.get(url="/dcl/model/versions/4447/8194/1011", payload=data)
78+
data = mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
7279
result = await check_for_update(MagicMock(), 4447, 8194, 1000, 1011)
7380

7481
assert result == data["modelVersion"]
@@ -77,14 +84,10 @@ async def test_check_updates_specific_version(aioresponse):
7784
async def test_check_no_update_if_url_empty(aioresponse):
7885
"""Test the case checks if latest version gets picked version."""
7986
# Call the function with a current software version of 1000 and request 1011 as update
80-
data = _load_fixture("4442-67.json")
81-
aioresponse.get(url="/dcl/model/versions/4442/67", payload=data)
82-
data = _load_fixture("4442-67-197888.json")
83-
aioresponse.get(url="/dcl/model/versions/4442/67/197888", payload=data)
84-
data = _load_fixture("4442-67-197910.json")
85-
aioresponse.get(url="/dcl/model/versions/4442/67/197910", payload=data)
86-
data = _load_fixture("4442-67-198340.json")
87-
aioresponse.get(url="/dcl/model/versions/4442/67/198340", payload=data)
87+
mock_dcl_version(aioresponse, 4442, 67)
88+
mock_dcl_version(aioresponse, 4442, 67, 197888)
89+
mock_dcl_version(aioresponse, 4442, 67, 197910)
90+
mock_dcl_version(aioresponse, 4442, 67, 198340)
8891
result = await check_for_update(MagicMock(), 4442, 67, 197120)
8992

9093
assert result is None

0 commit comments

Comments
 (0)