Read region from config and handle payload
The config file has 'region' under 'service' group but the code was looking for it in the default section. The payload instance doesn't have 'readable' method always. Removing the condition check and test per review comments. Change-Id: I8da70ebfa1ef73b7613ea6a179ad5cd4b31921ee
This commit is contained in:
parent
8c0864a001
commit
b61b6afa82
|
@ -213,12 +213,6 @@ class LogsCreatorPayload(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.instance = common_service.LogCreator()
|
||||
|
||||
@mock.patch('io.IOBase')
|
||||
def test_should_fail_for_unreadable_payload(self, payload):
|
||||
payload.configure_mock(**{'readable.return_value': False})
|
||||
self.assertRaises(falcon.HTTPInternalServerError,
|
||||
self.instance._read_payload, payload, 'a')
|
||||
|
||||
@mock.patch('io.IOBase')
|
||||
def test_should_read_text_for_plain_text(self, payload):
|
||||
msg = u'Hello World'
|
||||
|
|
|
@ -139,16 +139,10 @@ class LogCreator(object):
|
|||
def _create_meta_info(self, tenant_id):
|
||||
return {
|
||||
'tenantId': tenant_id,
|
||||
'region': cfg.CONF.get('region')
|
||||
'region': cfg.CONF.service.region
|
||||
}
|
||||
|
||||
def _read_payload(self, payload, content_type):
|
||||
if not payload.readable():
|
||||
self._log.error('Payload cannot be read, stream not readable')
|
||||
raise falcon.HTTPInternalServerError(
|
||||
title='Invalid message',
|
||||
description='Couldn\'t read the message'
|
||||
)
|
||||
|
||||
try:
|
||||
content = payload.read()
|
||||
|
|
Loading…
Reference in New Issue