mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add tests for Netatmo climate (#46392)
* Add tests for Netatmo climate * Add comments and fake webhook events * Split tests * Split tests * Clean up * Fix coveragerc * Fix requirements * Remove freezegun dependency * Move async_block_till_done to * Call async_handle_webhook directly * Use async_handle_webhook directly p2 * Exclude helper.py from * Remove assertion of implementation details * Use the webhook integration handler * Extract function
This commit is contained in:
44
tests/components/netatmo/common.py
Normal file
44
tests/components/netatmo/common.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Common methods used across tests for Netatmo."""
|
||||
import json
|
||||
|
||||
from tests.common import load_fixture
|
||||
|
||||
CLIENT_ID = "1234"
|
||||
CLIENT_SECRET = "5678"
|
||||
ALL_SCOPES = [
|
||||
"read_station",
|
||||
"read_camera",
|
||||
"access_camera",
|
||||
"write_camera",
|
||||
"read_presence",
|
||||
"access_presence",
|
||||
"write_presence",
|
||||
"read_homecoach",
|
||||
"read_smokedetector",
|
||||
"read_thermostat",
|
||||
"write_thermostat",
|
||||
]
|
||||
|
||||
|
||||
def fake_post_request(**args):
|
||||
"""Return fake data."""
|
||||
if "url" not in args:
|
||||
return "{}"
|
||||
|
||||
endpoint = args["url"].split("/")[-1]
|
||||
if endpoint in [
|
||||
"setpersonsaway",
|
||||
"setpersonshome",
|
||||
"setstate",
|
||||
"setroomthermpoint",
|
||||
"setthermmode",
|
||||
"switchhomeschedule",
|
||||
]:
|
||||
return f'{{"{endpoint}": true}}'
|
||||
|
||||
return json.loads(load_fixture(f"netatmo/{endpoint}.json"))
|
||||
|
||||
|
||||
def fake_post_request_no_data(**args):
|
||||
"""Fake error during requesting backend data."""
|
||||
return "{}"
|
||||
Reference in New Issue
Block a user