summaryrefslogtreecommitdiff
path: root/ceilometer/tests/unit/meter/test_notifications.py
diff options
context:
space:
mode:
Diffstat (limited to 'ceilometer/tests/unit/meter/test_notifications.py')
-rw-r--r--ceilometer/tests/unit/meter/test_notifications.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/ceilometer/tests/unit/meter/test_notifications.py b/ceilometer/tests/unit/meter/test_notifications.py
index d1dec075..9a12120f 100644
--- a/ceilometer/tests/unit/meter/test_notifications.py
+++ b/ceilometer/tests/unit/meter/test_notifications.py
@@ -141,19 +141,23 @@ FULL_MULTI_MSG = {
'payload': [{
'counter_name': 'instance1',
'user_id': 'user1',
+ 'user_name': 'test-resource',
'resource_id': 'res1',
'counter_unit': 'ns',
'counter_volume': 28.0,
'project_id': 'proj1',
+ 'project_name': 'test-resource',
'counter_type': 'gauge'
},
{
'counter_name': 'instance2',
'user_id': 'user2',
+ 'user_name': 'test-resource',
'resource_id': 'res2',
'counter_unit': '%',
'counter_volume': 1.0,
'project_id': 'proj2',
+ 'project_name': 'test-resource',
'counter_type': 'delta'
}],
'ctxt': {'domain': None,
@@ -615,7 +619,16 @@ class TestMeterProcessing(test.BaseTestCase):
c = list(self.handler.build_sample(event))
self.assertEqual(0, len(c))
- def test_multi_meter_payload_all_multi(self):
+ @mock.patch('ceilometer.cache_utils.resolve_uuid_from_cache')
+ def test_multi_meter_payload_all_multi(self, fake_cached_resource_name):
+
+ # return "test-resource" as the name of the user and project from cache
+ fake_cached_resource_name.return_value = "test-resource"
+
+ # expect user_name and project_name values to be set to "test-resource"
+ fake_user_name = "test-resource"
+ fake_project_name = "test-resource"
+
cfg = yaml.dump(
{'metric': [dict(name="$.payload.[*].counter_name",
event_type="full.sample",
@@ -640,6 +653,8 @@ class TestMeterProcessing(test.BaseTestCase):
self.assertEqual(msg[idx]['resource_id'], s1['resource_id'])
self.assertEqual(msg[idx]['project_id'], s1['project_id'])
self.assertEqual(msg[idx]['user_id'], s1['user_id'])
+ self.assertEqual(fake_user_name, s1['user_name'])
+ self.assertEqual(fake_project_name, s1['project_name'])
@mock.patch('ceilometer.meter.notifications.LOG')
def test_multi_meter_payload_invalid_missing(self, LOG):