exposed content_type in rest_command (#7101)
* exposed content_type in rest_command, which allows for manually specifying the content_type for more-strict api endpoints * fixed up column length Length was 86 chars, and it needed to be 79 * double import of HTTP_HEADER_CONTENT_TYPE Removed the accidental double-import of HTTP_HEADER_CONTENT_TYPE * moved rest_command-specific config value into component * if no content_type, default to None * unit test * newline * unused CONTENT_TYPE_TEXT_PLAIN * removed the http-agnostic abstraction hass provided in favor of aiohttps hdrs constant
This commit is contained in:
1 parent
43799b8fee
commit
226066eafd
2 files changed
+30
-1
No files matched your search
@@ -221,3 +221,22 @@ class TestRestCommandComponent(object):
|
||||
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
assert aioclient_mock.mock_calls[0][2] == b'data'
|
||||
|
||||
def test_rest_command_content_type(self, aioclient_mock):
|
||||
"""Call a rest command with a content type."""
|
||||
data = {
|
||||
'payload': 'item',
|
||||
'content_type': 'text/plain'
|
||||
}
|
||||
self.config[rc.DOMAIN]['post_test'].update(data)
|
||||
|
||||
with assert_setup_component(4):
|
||||
setup_component(self.hass, rc.DOMAIN, self.config)
|
||||
|
||||
aioclient_mock.post(self.url, content=b'success')
|
||||
|
||||
self.hass.services.call(rc.DOMAIN, 'post_test', {})
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
assert aioclient_mock.mock_calls[0][2] == b'item'
|
||||
Reference in new issue
Block a user