summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Pavlovic <boris@pavlovic.me>2014-07-02 19:34:12 +0400
committerBoris Pavlovic <boris@pavlovic.me>2014-07-02 19:34:12 +0400
commit587bd6499b4b4682e26801467a639a845a79a4f3 (patch)
treed738ea32c6b00f989788319baa47448bcd8a559b
parent7c38e311cf51d3eed819e7ff948a7bc4feb65b6d (diff)
downloadosprofiler-587bd6499b4b4682e26801467a639a845a79a4f3.tar.gz
Improve ceilometer notifications getter
Ceilometer client returns objects instead of dicts, that are requires by notification parsers, so do to_dict() to all objects to covert them inside get_notifications() method Change-Id: I85bc07fbe099fa3d9a5c1a36b649c991e01b955d
-rw-r--r--osprofiler/parsers/ceilometer.py3
-rw-r--r--tests/parsers/test_ceilometer.py5
2 files changed, 5 insertions, 3 deletions
diff --git a/osprofiler/parsers/ceilometer.py b/osprofiler/parsers/ceilometer.py
index 1683f5c..9e59bac 100644
--- a/osprofiler/parsers/ceilometer.py
+++ b/osprofiler/parsers/ceilometer.py
@@ -123,4 +123,5 @@ def get_notifications(ceilometer, base_id):
"""
_filter = '{"=": {"resource_id": "profiler-%s"}}' % base_id
- return ceilometer.query_samples.query(_filter, None, None)
+ return [n.to_dict()
+ for n in ceilometer.query_samples.query(_filter, None, None)]
diff --git a/tests/parsers/test_ceilometer.py b/tests/parsers/test_ceilometer.py
index 7a61e4b..6653c7d 100644
--- a/tests/parsers/test_ceilometer.py
+++ b/tests/parsers/test_ceilometer.py
@@ -230,7 +230,8 @@ class CeilometerParserTestCase(test.TestCase):
def test_get_notifications(self):
mock_ceil_client = mock.MagicMock()
- mock_ceil_client.query_samples.query.return_value = "result"
+ results = [mock.MagicMock(), mock.MagicMock()]
+ mock_ceil_client.query_samples.query.return_value = results
base_id = "10"
result = ceilometer.get_notifications(mock_ceil_client, base_id)
@@ -238,4 +239,4 @@ class CeilometerParserTestCase(test.TestCase):
expected_filter = '{"=": {"resource_id": "profiler-%s"}}' % base_id
mock_ceil_client.query_samples.query.assert_called_once_with(
expected_filter, None, None)
- self.assertEqual(result, "result")
+ self.assertEqual(result, [results[0].to_dict(), results[1].to_dict()])