|
38 | 38 | } |
39 | 39 |
|
40 | 40 |
|
| 41 | +async def test_factory_reset(aioclient_mock: AiohttpClientMocker) -> None: |
| 42 | + """Test factory_reset.""" |
| 43 | + otbr = python_otbr_api.OTBR(BASE_URL, aioclient_mock.create_session()) |
| 44 | + |
| 45 | + aioclient_mock.delete(f"{BASE_URL}/node", status=HTTPStatus.OK) |
| 46 | + |
| 47 | + await otbr.factory_reset() |
| 48 | + assert aioclient_mock.call_count == 1 |
| 49 | + assert aioclient_mock.mock_calls[-1][0] == "DELETE" |
| 50 | + assert aioclient_mock.mock_calls[-1][1].path == "/node" |
| 51 | + assert aioclient_mock.mock_calls[-1][2] is None |
| 52 | + |
| 53 | + |
| 54 | +async def test_factory_reset_unsupported(aioclient_mock: AiohttpClientMocker) -> None: |
| 55 | + """Test factory_reset is unsupported.""" |
| 56 | + otbr = python_otbr_api.OTBR(BASE_URL, aioclient_mock.create_session()) |
| 57 | + |
| 58 | + aioclient_mock.delete(f"{BASE_URL}/node", status=HTTPStatus.METHOD_NOT_ALLOWED) |
| 59 | + |
| 60 | + with pytest.raises(python_otbr_api.FactoryResetNotSupportedError): |
| 61 | + await otbr.factory_reset() |
| 62 | + |
| 63 | + |
| 64 | +async def test_factory_reset_201(aioclient_mock: AiohttpClientMocker) -> None: |
| 65 | + """Test factory_reset with error.""" |
| 66 | + otbr = python_otbr_api.OTBR(BASE_URL, aioclient_mock.create_session()) |
| 67 | + |
| 68 | + aioclient_mock.delete(f"{BASE_URL}/node", status=HTTPStatus.CREATED) |
| 69 | + |
| 70 | + with pytest.raises(python_otbr_api.OTBRError): |
| 71 | + await otbr.factory_reset() |
| 72 | + |
| 73 | + |
41 | 74 | async def test_set_enabled(aioclient_mock: AiohttpClientMocker) -> None: |
42 | 75 | """Test set_enabled.""" |
43 | 76 | otbr = python_otbr_api.OTBR(BASE_URL, aioclient_mock.create_session()) |
|
0 commit comments