Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Dec 27, 2024
1 parent e28f7f8 commit 738baa9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/evohome/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def request(
kwargs["json"] = convert_keys_to_camel_case(kwargs["json"])

try:
response = await self._make_request(method, url, **kwargs)
response = await self._request(method, url, **kwargs)
except exc.ApiRequestFailedError as err:
if err.status != HTTPStatus.UNAUTHORIZED: # 401
# leave it up to higher layers to handle the 401 as they can either be
Expand All @@ -255,7 +255,7 @@ async def _headers(self, headers: dict[str, str]) -> dict[str, str]:
This could take the form of an access token, or a session id.
"""

async def _make_request(
async def _request(
self, method: HTTPMethod, url: StrOrURL, /, **kwargs: Any
) -> dict[str, Any] | list[dict[str, Any]]:
"""Make a GET/PUT request to the Resideo TCC RESTful API.
Expand Down
12 changes: 6 additions & 6 deletions tests/tests_rf/test_v0_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def _post_session(auth: Auth) -> TccSessionResponseT:
async def get_account_info(auth: Auth) -> TccUserAccountInfoResponseT:
"""Test GET /accountInfo"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
"accountInfo",
) # type: ignore[return-value]
Expand All @@ -57,7 +57,7 @@ async def get_account_info(auth: Auth) -> TccUserAccountInfoResponseT:
async def get_comm_tasks(auth: Auth, tsk_id: int) -> dict[str, Any]:
"""Test GET /commTasks?commTaskId={tsk_id}"""

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"commTasks?commTaskId={tsk_id}",
) # type: ignore[return-value]
Expand All @@ -66,7 +66,7 @@ async def get_comm_tasks(auth: Auth, tsk_id: int) -> dict[str, Any]:
async def get_locations(auth: Auth, usr_id: int) -> list[TccLocationResponseT]:
"""Test GET /locations?userId={usr_id}&allData=True"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"locations?userId={usr_id}&allData=True",
) # type: ignore[return-value]
Expand All @@ -86,7 +86,7 @@ async def put_devices_dhw(auth: Auth, dhw_id: int) -> dict[str, Any]:

data = {"Status": "Scheduled"}

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"devices/{dhw_id}/thermostat/changeableValues",
data=data,
Expand All @@ -106,7 +106,7 @@ async def put_devices_zon(auth: Auth, zon_id: int) -> dict[str, Any]:

data = {"Status": "Scheduled"} # , "NextTime": None, "Value": None}

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"devices/{zon_id}/thermostat/changeableValues/heatSetpoint",
data=data,
Expand All @@ -123,7 +123,7 @@ async def put_evo_touch_systems(auth: Auth, loc_id: int) -> dict[str, Any]:

data = {"QuickAction": "Auto", "QuickActionNextTime": None}

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"evoTouchSystems?locationId={loc_id}",
data=data,
Expand Down
38 changes: 19 additions & 19 deletions tests/tests_rf/test_v2_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def _post_auth_oauth_oken(auth: Auth) -> dict[str, int | str]:
async def get_usr_account(auth: Auth) -> TccUsrAccountResponseT:
"""Test GET /userAccount"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
"userAccount",
) # type: ignore[return-value]
Expand All @@ -66,7 +66,7 @@ async def get_usr_account(auth: Auth) -> TccUsrAccountResponseT:
async def get_usr_locations(auth: Auth, usr_id: str) -> list[TccLocConfigResponseT]:
"""Test GET /location/installationInfo?userId={user_id}"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"location/installationInfo?userId={usr_id}&includeTemperatureControlSystems=True",
) # type: ignore[return-value]
Expand Down Expand Up @@ -127,7 +127,7 @@ async def test_tcs_urls(
async def get_loc_config(auth: Auth, loc_id: str) -> TccLocConfigResponseT:
"""Test GET /location/{loc_id}/installationInfo"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"location/{loc_id}/installationInfo?includeTemperatureControlSystems=True",
) # type: ignore[return-value]
Expand All @@ -136,7 +136,7 @@ async def get_loc_config(auth: Auth, loc_id: str) -> TccLocConfigResponseT:
async def get_loc_status(auth: Auth, loc_id: str) -> TccLocStatusResponseT:
"""Test GET /location/{loc_id}/status"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"location/{loc_id}/status?includeTemperatureControlSystems=True",
) # type: ignore[return-value]
Expand All @@ -145,7 +145,7 @@ async def get_loc_status(auth: Auth, loc_id: str) -> TccLocStatusResponseT:
async def get_tcs_status(auth: Auth, tcs_id: str) -> TccTcsStatusResponseT:
"""Test GET /temperatureControlSystem/{tcs_id}/status"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"temperatureControlSystem/{tcs_id}/status",
) # type: ignore[return-value]
Expand All @@ -154,7 +154,7 @@ async def get_tcs_status(auth: Auth, tcs_id: str) -> TccTcsStatusResponseT:
async def put_tcs_mode(auth: Auth, tcs_id: str) -> TccTaskResponseT:
"""Test PUT /temperatureControlSystem/{tcs_id}/mode"""

_ = await auth._make_request(
_ = await auth._request(
HTTPMethod.PUT,
f"temperatureControlSystem/{tcs_id}/mode",
json={
Expand All @@ -164,7 +164,7 @@ async def put_tcs_mode(auth: Auth, tcs_id: str) -> TccTaskResponseT:
},
)

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"temperatureControlSystem/{tcs_id}/mode",
json={"SystemMode": "Auto", "Permanent": True},
Expand Down Expand Up @@ -218,7 +218,7 @@ async def test_zon_urls(
async def get_zon_schedule(auth: Auth, zon_id: str) -> TccZonDailySchedulesT:
"""Test GET /temperatureZone/{zon_id}/schedule"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"temperatureZone/{zon_id}/schedule",
) # type: ignore[return-value]
Expand All @@ -227,7 +227,7 @@ async def get_zon_schedule(auth: Auth, zon_id: str) -> TccZonDailySchedulesT:
async def get_zon_status(auth: Auth, zon_id: str) -> TccZonStatusResponseT:
"""Test GET /temperatureZone/{zon_id}/status"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"temperatureZone/{zon_id}/status",
) # type: ignore[return-value]
Expand All @@ -236,7 +236,7 @@ async def get_zon_status(auth: Auth, zon_id: str) -> TccZonStatusResponseT:
async def put_zon_heat_setpoint(auth: Auth, zon_id: str) -> TccTaskResponseT:
"""Test PUT /temperatureZone/{zon_id}/heatSetpoint"""

_: TccTaskResponseT = await auth._make_request(
_: TccTaskResponseT = await auth._request(
HTTPMethod.PUT,
f"temperatureZone/{zon_id}/heatSetpoint",
json={
Expand All @@ -246,13 +246,13 @@ async def put_zon_heat_setpoint(auth: Auth, zon_id: str) -> TccTaskResponseT:
},
) # type: ignore[assignment]

_ = await auth._make_request(
_ = await auth._request(
HTTPMethod.PUT,
f"temperatureZone/{zon_id}/heatSetpoint",
json={"setpointMode": "PermanentOverride", "HeatSetpointValue": 20.5},
) # type: ignore[assignment]

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"temperatureZone/{zon_id}/heatSetpoint",
json={"setpointMode": "FollowSchedule"}, # , "HeatSetpointValue": None},
Expand All @@ -264,7 +264,7 @@ async def put_zon_schedule(
) -> TccTaskResponseT:
"""Test GET /temperatureZone/{zon_id}/schedule"""

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"temperatureZone/{zon_id}/schedule",
json=schedule,
Expand Down Expand Up @@ -324,7 +324,7 @@ async def test_dhw_urls(
async def get_dhw_schedule(auth: Auth, dhw_id: str) -> TccDhwDailySchedulesT:
"""Test GET /domesticHotWater/{dhw_id}/schedule"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"domesticHotWater/{dhw_id}/schedule",
) # type: ignore[return-value]
Expand All @@ -333,7 +333,7 @@ async def get_dhw_schedule(auth: Auth, dhw_id: str) -> TccDhwDailySchedulesT:
async def get_dhw_status(auth: Auth, dhw_id: str) -> TccDhwStatusResponseT:
"""Test GET /domesticHotWater/{dhw_id}/status"""

return await auth._make_request(
return await auth._request(
HTTPMethod.GET,
f"domesticHotWater/{dhw_id}/status",
) # type: ignore[return-value]
Expand All @@ -342,7 +342,7 @@ async def get_dhw_status(auth: Auth, dhw_id: str) -> TccDhwStatusResponseT:
async def put_dhw_state(auth: Auth, dhw_id: str) -> TccTaskResponseT:
"""Test PUT /domesticHotWater/{dhw_id}/state"""

_: TccTaskResponseT = await auth._make_request(
_: TccTaskResponseT = await auth._request(
HTTPMethod.PUT,
f"domesticHotWater/{dhw_id}/state",
json={
Expand All @@ -352,13 +352,13 @@ async def put_dhw_state(auth: Auth, dhw_id: str) -> TccTaskResponseT:
},
) # type: ignore[assignment]

_ = await auth._make_request(
_ = await auth._request(
HTTPMethod.PUT,
f"domesticHotWater/{dhw_id}/state",
json={"mode": "PermanentOverride", "state": "Off"},
) # type: ignore[assignment]

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"domesticHotWater/{dhw_id}/state",
json={"mode": "FollowSchedule"}, # , "state": None},
Expand All @@ -370,7 +370,7 @@ async def put_dhw_schedule(
) -> TccTaskResponseT:
"""Test GET /domesticHotWater/{dhw_id}/schedule"""

return await auth._make_request(
return await auth._request(
HTTPMethod.PUT,
f"domesticHotWater/{dhw_id}/schedule",
json=schedule,
Expand Down

0 comments on commit 738baa9

Please sign in to comment.