|
7 | 7 | import pytz |
8 | 8 |
|
9 | 9 | from simplipy import API |
10 | | -from simplipy.errors import InvalidCredentialsError, PinError, SimplipyError |
| 10 | +from simplipy.errors import ( |
| 11 | + EndpointUnavailable, |
| 12 | + InvalidCredentialsError, |
| 13 | + PinError, |
| 14 | + SimplipyError, |
| 15 | +) |
11 | 16 | from simplipy.system import SystemStates |
12 | 17 | from simplipy.system.v3 import VOLUME_HIGH, VOLUME_MEDIUM |
13 | 18 |
|
@@ -785,6 +790,31 @@ async def test_system_notifications(aresponses, v3_server, v3_subscriptions_resp |
785 | 790 | assert notification1.link_label == "More Info" |
786 | 791 |
|
787 | 792 |
|
| 793 | +@pytest.mark.asyncio |
| 794 | +async def test_unavailable_endpoint(aresponses, v3_server): |
| 795 | + """Test that an unavailable endpoint logs a message.""" |
| 796 | + async with v3_server: |
| 797 | + v3_server.add( |
| 798 | + "api.simplisafe.com", |
| 799 | + f"/v1/ss3/subscriptions/{TEST_SUBSCRIPTION_ID}/settings/normal", |
| 800 | + "get", |
| 801 | + aresponses.Response( |
| 802 | + text=load_fixture("unavailable_endpoint_response.json"), status=403 |
| 803 | + ), |
| 804 | + ) |
| 805 | + |
| 806 | + async with aiohttp.ClientSession() as session: |
| 807 | + simplisafe = await API.login_via_credentials( |
| 808 | + TEST_EMAIL, TEST_PASSWORD, client_id=TEST_CLIENT_ID, session=session |
| 809 | + ) |
| 810 | + |
| 811 | + systems = await simplisafe.get_systems() |
| 812 | + system = systems[TEST_SYSTEM_ID] |
| 813 | + |
| 814 | + with pytest.raises(EndpointUnavailable): |
| 815 | + await system.update(include_system=False, include_entities=False) |
| 816 | + |
| 817 | + |
788 | 818 | @pytest.mark.asyncio |
789 | 819 | @pytest.mark.parametrize( |
790 | 820 | "v3_subscriptions_response", |
|
0 commit comments