Improve coverage of test_queues and fix bug
This commit is contained in:
parent
5d8c1b97a0
commit
34f6eec42c
openstack_qa_tools
@ -53,7 +53,7 @@ def collect():
|
||||
for q in content:
|
||||
if not isinstance(q, dict):
|
||||
continue
|
||||
if "name" not in q or "messages" not in q:
|
||||
if "name" not in q:
|
||||
continue
|
||||
qname = q["name"]
|
||||
if qname.startswith('reply_'):
|
||||
|
@ -19,6 +19,7 @@ test_collectors
|
||||
Tests for `openstack_qa_tools.collectors`
|
||||
"""
|
||||
|
||||
import json
|
||||
import mock
|
||||
|
||||
from openstack_qa_tools.collectors import queues
|
||||
@ -30,8 +31,9 @@ class TestOpenStackQaTols(base.TestCase):
|
||||
@mock.patch('six.moves.http_client.HTTPConnection')
|
||||
def test_queues(self, httplib_mock):
|
||||
reader = mock.MagicMock(name='getresponse_reader')
|
||||
reader.read.return_value = '[]'
|
||||
rval = json.dumps([{'name': 'foo', 'message_stats': {'publish': 1}}])
|
||||
reader.read.return_value = rval
|
||||
conn = httplib_mock.return_value
|
||||
conn.getresponse.return_value = reader
|
||||
data = queues.collect()
|
||||
self.assertEqual({}, data)
|
||||
self.assertEqual({'foo_publish': 1}, data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user