|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 |
| -from unittest.mock import AsyncMock, call |
| 3 | +from unittest.mock import AsyncMock, call, patch |
4 | 4 |
|
5 | 5 | import pytest
|
6 | 6 |
|
@@ -181,3 +181,46 @@ async def test_xncp_get_flow_control_type(ezsp_f: EZSP) -> None:
|
181 | 181 | assert customFrame.mock_calls == [
|
182 | 182 | call(xncp.XncpCommand.from_payload(xncp.GetFlowControlTypeReq()).serialize())
|
183 | 183 | ]
|
| 184 | + |
| 185 | + |
| 186 | +async def test_xncp_get_xncp_features_fixes(ezsp_f: EZSP) -> None: |
| 187 | + """Test XNCP `get_xncp_features`, with fixes.""" |
| 188 | + ezsp_f._mock_commands["customFrame"] = customFrame = AsyncMock( |
| 189 | + return_value=[ |
| 190 | + t.EmberStatus.SUCCESS, |
| 191 | + xncp.XncpCommand.from_payload( |
| 192 | + xncp.GetSupportedFeaturesRsp( |
| 193 | + features=( |
| 194 | + xncp.FirmwareFeatures.MANUAL_SOURCE_ROUTE |
| 195 | + | xncp.FirmwareFeatures.MEMBER_OF_ALL_GROUPS |
| 196 | + ) |
| 197 | + ) |
| 198 | + ).serialize(), |
| 199 | + ] |
| 200 | + ) |
| 201 | + |
| 202 | + # In 7.4.4.0, it's broken |
| 203 | + with patch.object( |
| 204 | + ezsp_f, |
| 205 | + "get_board_info", |
| 206 | + return_value=("Model", "Manufacturer", "7.4.4.0 build 0"), |
| 207 | + ): |
| 208 | + assert ( |
| 209 | + await ezsp_f.get_xncp_features() |
| 210 | + ) == xncp.FirmwareFeatures.MANUAL_SOURCE_ROUTE |
| 211 | + |
| 212 | + # In a hypothetical new release, it's not |
| 213 | + with patch.object( |
| 214 | + ezsp_f, |
| 215 | + "get_board_info", |
| 216 | + return_value=("Model", "Manufacturer", "7.4.4.0 build 1"), |
| 217 | + ): |
| 218 | + assert (await ezsp_f.get_xncp_features()) == ( |
| 219 | + xncp.FirmwareFeatures.MANUAL_SOURCE_ROUTE |
| 220 | + | xncp.FirmwareFeatures.MEMBER_OF_ALL_GROUPS |
| 221 | + ) |
| 222 | + |
| 223 | + assert customFrame.mock_calls == [ |
| 224 | + call(xncp.XncpCommand.from_payload(xncp.GetSupportedFeaturesReq()).serialize()), |
| 225 | + call(xncp.XncpCommand.from_payload(xncp.GetSupportedFeaturesReq()).serialize()), |
| 226 | + ] |
0 commit comments