Use http.HTTPStatus in components/s* (#58291)
This commit is contained in:
parent
05671557f0
commit
50e0c58310
29 changed files with 180 additions and 158 deletions
|
@ -1,4 +1,5 @@
|
|||
"""Tests for the sigfox sensor."""
|
||||
from http import HTTPStatus
|
||||
import re
|
||||
|
||||
import requests_mock
|
||||
|
@ -34,7 +35,7 @@ async def test_invalid_credentials(hass):
|
|||
"""Test for invalid credentials."""
|
||||
with requests_mock.Mocker() as mock_req:
|
||||
url = re.compile(API_URL + "devicetypes")
|
||||
mock_req.get(url, text="{}", status_code=401)
|
||||
mock_req.get(url, text="{}", status_code=HTTPStatus.UNAUTHORIZED)
|
||||
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids()) == 0
|
||||
|
@ -44,7 +45,9 @@ async def test_valid_credentials(hass):
|
|||
"""Test for valid credentials."""
|
||||
with requests_mock.Mocker() as mock_req:
|
||||
url1 = re.compile(API_URL + "devicetypes")
|
||||
mock_req.get(url1, text='{"data":[{"id":"fake_type"}]}', status_code=200)
|
||||
mock_req.get(
|
||||
url1, text='{"data":[{"id":"fake_type"}]}', status_code=HTTPStatus.OK
|
||||
)
|
||||
|
||||
url2 = re.compile(API_URL + "devicetypes/fake_type/devices")
|
||||
mock_req.get(url2, text='{"data":[{"id":"fake_id"}]}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue