mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use http.HTTPStatus in components/[gh]* (#58246)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""The tests for the Geofency device tracker platform."""
|
||||
from http import HTTPStatus
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -11,8 +13,6 @@ from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import (
|
||||
ATTR_LATITUDE,
|
||||
ATTR_LONGITUDE,
|
||||
HTTP_OK,
|
||||
HTTP_UNPROCESSABLE_ENTITY,
|
||||
STATE_HOME,
|
||||
STATE_NOT_HOME,
|
||||
)
|
||||
@@ -172,7 +172,7 @@ async def test_data_validation(geofency_client, webhook_id):
|
||||
|
||||
# No data
|
||||
req = await geofency_client.post(url)
|
||||
assert req.status == HTTP_UNPROCESSABLE_ENTITY
|
||||
assert req.status == HTTPStatus.UNPROCESSABLE_ENTITY
|
||||
|
||||
missing_attributes = ["address", "device", "entry", "latitude", "longitude", "name"]
|
||||
|
||||
@@ -181,7 +181,7 @@ async def test_data_validation(geofency_client, webhook_id):
|
||||
copy = GPS_ENTER_HOME.copy()
|
||||
del copy[attribute]
|
||||
req = await geofency_client.post(url, data=copy)
|
||||
assert req.status == HTTP_UNPROCESSABLE_ENTITY
|
||||
assert req.status == HTTPStatus.UNPROCESSABLE_ENTITY
|
||||
|
||||
|
||||
async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
@@ -191,7 +191,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
# Enter the Home zone
|
||||
req = await geofency_client.post(url, data=GPS_ENTER_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(GPS_ENTER_HOME["device"])
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_HOME
|
||||
@@ -199,7 +199,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
# Exit the Home zone
|
||||
req = await geofency_client.post(url, data=GPS_EXIT_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(GPS_EXIT_HOME["device"])
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_NOT_HOME
|
||||
@@ -211,7 +211,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
|
||||
req = await geofency_client.post(url, data=data)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(GPS_EXIT_HOME["device"])
|
||||
current_latitude = hass.states.get(f"device_tracker.{device_name}").attributes[
|
||||
"latitude"
|
||||
@@ -236,7 +236,7 @@ async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
# Enter the Home zone
|
||||
req = await geofency_client.post(url, data=BEACON_ENTER_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_HOME
|
||||
@@ -244,7 +244,7 @@ async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id):
|
||||
# Exit the Home zone
|
||||
req = await geofency_client.post(url, data=BEACON_EXIT_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_NOT_HOME
|
||||
@@ -257,7 +257,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
|
||||
# Enter the Car away from Home zone
|
||||
req = await geofency_client.post(url, data=BEACON_ENTER_CAR)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_NOT_HOME
|
||||
@@ -265,7 +265,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
|
||||
# Exit the Car away from Home zone
|
||||
req = await geofency_client.post(url, data=BEACON_EXIT_CAR)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_NOT_HOME
|
||||
@@ -276,7 +276,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
|
||||
data["longitude"] = HOME_LONGITUDE
|
||||
req = await geofency_client.post(url, data=data)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{data['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_HOME
|
||||
@@ -284,7 +284,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
|
||||
# Exit the Car in the Home zone
|
||||
req = await geofency_client.post(url, data=data)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(f"beacon_{data['name']}")
|
||||
state_name = hass.states.get(f"device_tracker.{device_name}").state
|
||||
assert state_name == STATE_HOME
|
||||
@@ -297,7 +297,7 @@ async def test_load_unload_entry(hass, geofency_client, webhook_id):
|
||||
# Enter the Home zone
|
||||
req = await geofency_client.post(url, data=GPS_ENTER_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert req.status == HTTP_OK
|
||||
assert req.status == HTTPStatus.OK
|
||||
device_name = slugify(GPS_ENTER_HOME["device"])
|
||||
state_1 = hass.states.get(f"device_tracker.{device_name}")
|
||||
assert state_1.state == STATE_HOME
|
||||
|
||||
Reference in New Issue
Block a user