Skip to content

Commit d6a4158

Browse files
committed
Tests working
1 parent 32db030 commit d6a4158

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

poetry.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ safety = "3.0.1"
4949
yamllint = "1.33.0"
5050
syrupy = "4.6.1"
5151
deptry = "^0.19.1"
52+
asynctest = "^0.13.0"
5253

5354
[tool.coverage.report]
5455
show_missing = true

tests/test_ata_properties.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
import pytest
6-
from asynctest import CoroutineMock, Mock, patch
6+
from unittest.mock import AsyncMock, Mock, patch
77
from aiohttp.web import HTTPForbidden
88
from pymelcloud import DEVICE_TYPE_ATA
99
from pymelcloud.const import ACCESS_LEVEL
@@ -43,11 +43,11 @@ def _build_device(device_conf_name: str, device_state_name: str) -> AtaDevice:
4343
device_state = json.load(json_file)
4444

4545
with patch("pymelcloud.client.Client") as _client:
46-
_client.update_confs = CoroutineMock()
46+
_client.update_confs = AsyncMock()
4747
_client.device_confs.__iter__ = Mock(return_value=[device_conf].__iter__())
48-
_client.fetch_device_units = CoroutineMock(return_value=[])
49-
_client.fetch_device_state = CoroutineMock(return_value=device_state)
50-
_client.fetch_energy_report = CoroutineMock(return_value=None)
48+
_client.fetch_device_units = AsyncMock(return_value=[])
49+
_client.fetch_device_state = AsyncMock(return_value=device_state)
50+
_client.fetch_energy_report = AsyncMock(return_value=None)
5151
client = _client
5252

5353
return AtaDevice(device_conf, client)
@@ -95,7 +95,7 @@ async def test_ata():
9595
@pytest.mark.asyncio
9696
async def test_ata_guest():
9797
device = _build_device("ata_guest_listdevices.json", "ata_guest_get.json")
98-
device._client.fetch_device_units = CoroutineMock(side_effect=HTTPForbidden)
98+
device._client.fetch_device_units = AsyncMock(side_effect=HTTPForbidden)
9999
assert device.device_type == DEVICE_TYPE_ATA
100100
assert device.access_level == ACCESS_LEVEL["GUEST"]
101101
await device.update()

tests/test_device.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
from typing import Any, Dict, Optional
33

44
import pytest
5+
from unittest.mock import AsyncMock, Mock, patch
56
from pymelcloud.ata_device import AtaDevice
67
from .util import build_device
78

89

9-
def _build_device(device_conf_name: str, device_state_name: str, energy_report: Optional[Dict[Any, Any]]=None) -> AtaDevice:
10+
def _build_device(device_conf_name: str, device_state_name: str, energy_report: Optional[Dict[Any, Any]] = None) -> AtaDevice:
1011
device_conf, client = build_device(device_conf_name, device_state_name, energy_report)
1112
return AtaDevice(device_conf, client)
1213

tests/test_erv_properties.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
import pytest
6-
from asynctest import CoroutineMock, Mock, patch
6+
from unittest.mock import AsyncMock, Mock, patch
77
from pymelcloud import DEVICE_TYPE_ERV
88
from pymelcloud.erv_device import (
99
VENTILATION_MODE_AUTO,
@@ -22,11 +22,11 @@ def _build_device(device_conf_name: str, device_state_name: str) -> ErvDevice:
2222
device_state = json.load(json_file)
2323

2424
with patch("pymelcloud.client.Client") as _client:
25-
_client.update_confs = CoroutineMock()
25+
_client.update_confs = AsyncMock()
2626
_client.device_confs.__iter__ = Mock(return_value=[device_conf].__iter__())
27-
_client.fetch_device_units = CoroutineMock(return_value=[])
28-
_client.fetch_device_state = CoroutineMock(return_value=device_state)
29-
_client.fetch_energy_report = CoroutineMock(return_value=None)
27+
_client.fetch_device_units = AsyncMock(return_value=[])
28+
_client.fetch_device_state = AsyncMock(return_value=device_state)
29+
_client.fetch_energy_report = AsyncMock(return_value=None)
3030
client = _client
3131

3232
return ErvDevice(device_conf, client)

tests/util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
from typing import Any, Dict, Optional
44

5-
from asynctest import CoroutineMock, Mock, patch
5+
from unittest.mock import AsyncMock, Mock, patch
66

77
def build_device(device_conf_name: str, device_state_name: str, energy_report: Optional[Dict[Any, Any]]=None):
88
test_dir = os.path.join(os.path.dirname(__file__), "samples")
@@ -13,11 +13,11 @@ def build_device(device_conf_name: str, device_state_name: str, energy_report: O
1313
device_state = json.load(json_file)
1414

1515
with patch("pymelcloud.client.Client") as _client:
16-
_client.update_confs = CoroutineMock()
16+
_client.update_confs = AsyncMock()
1717
_client.device_confs.__iter__ = Mock(return_value=[device_conf].__iter__())
18-
_client.fetch_device_units = CoroutineMock(return_value=[])
19-
_client.fetch_device_state = CoroutineMock(return_value=device_state)
20-
_client.fetch_energy_report = CoroutineMock(return_value=energy_report)
18+
_client.fetch_device_units = AsyncMock(return_value=[])
19+
_client.fetch_device_state = AsyncMock(return_value=device_state)
20+
_client.fetch_energy_report = AsyncMock(return_value=energy_report)
2121
client = _client
2222

2323
return device_conf, client

0 commit comments

Comments
 (0)