mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Use content type text plain constant (#40313)
This commit is contained in:
parent
4f5d3b4035
commit
0c077685b6
@ -9,6 +9,7 @@ from homeassistant.components.demo.sensor import DemoSensor
|
||||
import homeassistant.components.prometheus as prometheus
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONTENT_TYPE_TEXT_PLAIN,
|
||||
DEGREE,
|
||||
DEVICE_CLASS_POWER,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
@ -97,7 +98,7 @@ async def test_view(hass, hass_client):
|
||||
resp = await client.get(prometheus.API_ENDPOINT)
|
||||
|
||||
assert resp.status == 200
|
||||
assert resp.headers["content-type"] == "text/plain"
|
||||
assert resp.headers["content-type"] == CONTENT_TYPE_TEXT_PLAIN
|
||||
body = await resp.text()
|
||||
body = body.split("\n")
|
||||
|
||||
|
@ -12,7 +12,7 @@ import requests_mock
|
||||
from homeassistant import config as hass_config
|
||||
import homeassistant.components.rest.sensor as rest
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.const import DATA_MEGABYTES, SERVICE_RELOAD
|
||||
from homeassistant.const import CONTENT_TYPE_TEXT_PLAIN, DATA_MEGABYTES, SERVICE_RELOAD
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.config_validation import template
|
||||
from homeassistant.setup import async_setup_component, setup_component
|
||||
@ -413,7 +413,7 @@ class TestRestSensor(unittest.TestCase):
|
||||
"rest.RestData.update",
|
||||
side_effect=self.update_side_effect(
|
||||
"This is text rather than JSON data.",
|
||||
CaseInsensitiveDict({"Content-Type": "text/plain"}),
|
||||
CaseInsensitiveDict({"Content-Type": CONTENT_TYPE_TEXT_PLAIN}),
|
||||
),
|
||||
)
|
||||
self.sensor = rest.RestSensor(
|
||||
|
@ -4,6 +4,7 @@ import asyncio
|
||||
import aiohttp
|
||||
|
||||
import homeassistant.components.rest_command as rc
|
||||
from homeassistant.const import CONTENT_TYPE_TEXT_PLAIN
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import assert_setup_component, get_test_home_assistant
|
||||
@ -218,7 +219,7 @@ class TestRestCommandComponent:
|
||||
header_config_variations = {
|
||||
rc.DOMAIN: {
|
||||
"no_headers_test": {},
|
||||
"content_type_test": {"content_type": "text/plain"},
|
||||
"content_type_test": {"content_type": CONTENT_TYPE_TEXT_PLAIN},
|
||||
"headers_test": {
|
||||
"headers": {
|
||||
"Accept": "application/json",
|
||||
@ -227,14 +228,14 @@ class TestRestCommandComponent:
|
||||
},
|
||||
"headers_and_content_type_test": {
|
||||
"headers": {"Accept": "application/json"},
|
||||
"content_type": "text/plain",
|
||||
"content_type": CONTENT_TYPE_TEXT_PLAIN,
|
||||
},
|
||||
"headers_and_content_type_override_test": {
|
||||
"headers": {
|
||||
"Accept": "application/json",
|
||||
aiohttp.hdrs.CONTENT_TYPE: "application/pdf",
|
||||
},
|
||||
"content_type": "text/plain",
|
||||
"content_type": CONTENT_TYPE_TEXT_PLAIN,
|
||||
},
|
||||
"headers_template_test": {
|
||||
"headers": {
|
||||
@ -285,7 +286,7 @@ class TestRestCommandComponent:
|
||||
assert len(aioclient_mock.mock_calls[1][3]) == 1
|
||||
assert (
|
||||
aioclient_mock.mock_calls[1][3].get(aiohttp.hdrs.CONTENT_TYPE)
|
||||
== "text/plain"
|
||||
== CONTENT_TYPE_TEXT_PLAIN
|
||||
)
|
||||
|
||||
# headers_test
|
||||
@ -297,7 +298,7 @@ class TestRestCommandComponent:
|
||||
assert len(aioclient_mock.mock_calls[3][3]) == 2
|
||||
assert (
|
||||
aioclient_mock.mock_calls[3][3].get(aiohttp.hdrs.CONTENT_TYPE)
|
||||
== "text/plain"
|
||||
== CONTENT_TYPE_TEXT_PLAIN
|
||||
)
|
||||
assert aioclient_mock.mock_calls[3][3].get("Accept") == "application/json"
|
||||
|
||||
@ -305,7 +306,7 @@ class TestRestCommandComponent:
|
||||
assert len(aioclient_mock.mock_calls[4][3]) == 2
|
||||
assert (
|
||||
aioclient_mock.mock_calls[4][3].get(aiohttp.hdrs.CONTENT_TYPE)
|
||||
== "text/plain"
|
||||
== CONTENT_TYPE_TEXT_PLAIN
|
||||
)
|
||||
assert aioclient_mock.mock_calls[4][3].get("Accept") == "application/json"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user