summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiaozhuangqing <zhuangqing.xiao@easystack.cn>2016-07-29 10:47:04 +0800
committerxiaozhuangqing <zhuangqing.xiao@easystack.cn>2016-07-29 11:08:36 +0800
commit481cd7d33bf5f91c39888fa695238c562eda7945 (patch)
tree8bf34cf5e532ef0eabb8d9238dd9d72b60e10f55
parent3b35aea69e8618331d85aafe6347572e1db06cd5 (diff)
downloadpython-ceilometerclient-481cd7d33bf5f91c39888fa695238c562eda7945.tar.gz
Correct the parameters's position of assertEqual
assertEqual using should be assertEqual(expected, actual) misplace have two impacts: 1.giving confusing messages when some tests failed. 2.mislead other developer,new test modules may follow these wrong pattern see Partial-Bug https://bugs.launchpad.net/oslo.config/+bug/1604213 Change-Id: I4467d5efb1eed9f4c473c947c93afcfaf9be6ea6
-rw-r--r--ceilometerclient/tests/unit/v2/test_alarms.py22
-rw-r--r--ceilometerclient/tests/unit/v2/test_event_types.py10
-rw-r--r--ceilometerclient/tests/unit/v2/test_resources.py12
-rw-r--r--ceilometerclient/tests/unit/v2/test_samples.py8
-rw-r--r--ceilometerclient/tests/unit/v2/test_statistics.py22
-rw-r--r--ceilometerclient/tests/unit/v2/test_trait_descriptions.py2
-rw-r--r--ceilometerclient/tests/unit/v2/test_traits.py2
7 files changed, 39 insertions, 39 deletions
diff --git a/ceilometerclient/tests/unit/v2/test_alarms.py b/ceilometerclient/tests/unit/v2/test_alarms.py
index 7511557..44fa50c 100644
--- a/ceilometerclient/tests/unit/v2/test_alarms.py
+++ b/ceilometerclient/tests/unit/v2/test_alarms.py
@@ -279,8 +279,8 @@ class AlarmManagerTest(testtools.TestCase):
'GET', '/v2/alarms'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(alarms), 1)
- self.assertEqual(alarms[0].alarm_id, 'alarm-id')
+ self.assertEqual(1, len(alarms))
+ self.assertEqual('alarm-id', alarms[0].alarm_id)
def test_list_with_query(self):
alarms = list(self.mgr.list(q=[{"field": "project_id",
@@ -293,8 +293,8 @@ class AlarmManagerTest(testtools.TestCase):
'&q.type=&q.type=&q.value=project-id&q.value=SwiftObjectAlarm',
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(alarms), 1)
- self.assertEqual(alarms[0].alarm_id, 'alarm-id')
+ self.assertEqual(1, len(alarms))
+ self.assertEqual('alarm-id', alarms[0].alarm_id)
def test_get(self):
alarm = self.mgr.get(alarm_id='alarm-id')
@@ -303,7 +303,7 @@ class AlarmManagerTest(testtools.TestCase):
]
self.http_client.assert_called(*expect)
self.assertIsNotNone(alarm)
- self.assertEqual(alarm.alarm_id, 'alarm-id')
+ self.assertEqual('alarm-id', alarm.alarm_id)
self.assertEqual(alarm.rule, alarm.threshold_rule)
def test_create(self):
@@ -325,7 +325,7 @@ class AlarmManagerTest(testtools.TestCase):
self.http_client.assert_called(*expect_get, pos=0)
self.http_client.assert_called(*expect_put, pos=1)
self.assertIsNotNone(alarm)
- self.assertEqual(alarm.alarm_id, 'alarm-id')
+ self.assertEqual('alarm-id', alarm.alarm_id)
for (key, value) in six.iteritems(UPDATED_ALARM):
self.assertEqual(getattr(alarm, key), value)
@@ -340,7 +340,7 @@ class AlarmManagerTest(testtools.TestCase):
self.http_client.assert_called(*expect_get, pos=0)
self.http_client.assert_called(*expect_put, pos=1)
self.assertIsNotNone(alarm)
- self.assertEqual(alarm.alarm_id, 'alarm-id')
+ self.assertEqual('alarm-id', alarm.alarm_id)
for (key, value) in six.iteritems(UPDATED_ALARM):
self.assertEqual(getattr(alarm, key), value)
@@ -350,7 +350,7 @@ class AlarmManagerTest(testtools.TestCase):
'PUT', '/v2/alarms/alarm-id/state'
]
self.http_client.assert_called(*expect, body='alarm')
- self.assertEqual(state, {'alarm': 'alarm'})
+ self.assertEqual({'alarm': 'alarm'}, state)
def test_get_state(self):
state = self.mgr.get_state(alarm_id='alarm-id')
@@ -358,7 +358,7 @@ class AlarmManagerTest(testtools.TestCase):
'GET', '/v2/alarms/alarm-id/state'
]
self.http_client.assert_called(*expect)
- self.assertEqual(state, {'alarm': 'alarm'})
+ self.assertEqual({'alarm': 'alarm'}, state)
def test_delete(self):
deleted = self.mgr.delete(alarm_id='victim-id')
@@ -472,7 +472,7 @@ class AlarmLegacyManagerTest(testtools.TestCase):
]
self.http_client.assert_called(*expect_put)
self.assertIsNotNone(alarm)
- self.assertEqual(alarm.alarm_id, 'alarm-id')
+ self.assertEqual('alarm-id', alarm.alarm_id)
for (key, value) in six.iteritems(UPDATED_ALARM):
self.assertEqual(getattr(alarm, key), value)
@@ -487,7 +487,7 @@ class AlarmLegacyManagerTest(testtools.TestCase):
]
self.http_client.assert_called(*expect_put)
self.assertIsNotNone(alarm)
- self.assertEqual(alarm.alarm_id, 'alarm-id')
+ self.assertEqual('alarm-id', alarm.alarm_id)
for (key, value) in six.iteritems(UPDATED_ALARM):
self.assertEqual(getattr(alarm, key), value)
diff --git a/ceilometerclient/tests/unit/v2/test_event_types.py b/ceilometerclient/tests/unit/v2/test_event_types.py
index 7dc1508..518e853 100644
--- a/ceilometerclient/tests/unit/v2/test_event_types.py
+++ b/ceilometerclient/tests/unit/v2/test_event_types.py
@@ -43,8 +43,8 @@ class EventTypesManagerTest(utils.BaseTestCase):
'GET', '/v2/event_types/'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(event_types), 4)
- self.assertEqual(event_types[0].event_type, "Foo")
- self.assertEqual(event_types[1].event_type, "Bar")
- self.assertEqual(event_types[2].event_type, "Sna")
- self.assertEqual(event_types[3].event_type, "Fu")
+ self.assertEqual(4, len(event_types))
+ self.assertEqual("Foo", event_types[0].event_type)
+ self.assertEqual("Bar", event_types[1].event_type)
+ self.assertEqual("Sna", event_types[2].event_type)
+ self.assertEqual("Fu", event_types[3].event_type)
diff --git a/ceilometerclient/tests/unit/v2/test_resources.py b/ceilometerclient/tests/unit/v2/test_resources.py
index 3c19654..a03f88b 100644
--- a/ceilometerclient/tests/unit/v2/test_resources.py
+++ b/ceilometerclient/tests/unit/v2/test_resources.py
@@ -100,9 +100,9 @@ class ResourceManagerTest(utils.BaseTestCase):
'GET', '/v2/resources?meter_links=0'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(resources), 2)
- self.assertEqual(resources[0].resource_id, 'a')
- self.assertEqual(resources[1].resource_id, 'b')
+ self.assertEqual(2, len(resources))
+ self.assertEqual('a', resources[0].resource_id)
+ self.assertEqual('b', resources[1].resource_id)
def test_list_all_with_links_enabled(self):
resources = list(self.mgr.list(links=True))
@@ -121,7 +121,7 @@ class ResourceManagerTest(utils.BaseTestCase):
]
self.http_client.assert_called(*expect)
self.assertIsNotNone(resource)
- self.assertEqual(resource.resource_id, 'a')
+ self.assertEqual('a', resource.resource_id)
def test_list_by_query(self):
resources = list(self.mgr.list(q=[{"field": "resource_id",
@@ -132,8 +132,8 @@ class ResourceManagerTest(utils.BaseTestCase):
'&q.type=&q.value=a&meter_links=0'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(resources), 1)
- self.assertEqual(resources[0].resource_id, 'a')
+ self.assertEqual(1, len(resources))
+ self.assertEqual('a', resources[0].resource_id)
def test_get_from_resource_class(self):
resource = self.mgr.get(resource_id='a')
diff --git a/ceilometerclient/tests/unit/v2/test_samples.py b/ceilometerclient/tests/unit/v2/test_samples.py
index 3a4cbd0..63a70fc 100644
--- a/ceilometerclient/tests/unit/v2/test_samples.py
+++ b/ceilometerclient/tests/unit/v2/test_samples.py
@@ -147,8 +147,8 @@ class OldSampleManagerTest(utils.BaseTestCase):
'GET', '/v2/meters/instance'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(samples), 1)
- self.assertEqual(samples[0].resource_id, 'resource-id')
+ self.assertEqual(1, len(samples))
+ self.assertEqual('resource-id', samples[0].resource_id)
def test_list_by_meter_name_extended(self):
samples = list(self.mgr.list(meter_name='instance',
@@ -160,7 +160,7 @@ class OldSampleManagerTest(utils.BaseTestCase):
]))
expect = ['GET', '%s?%s' % (METER_URL, QUERIES)]
self.http_client.assert_called(*expect)
- self.assertEqual(len(samples), 0)
+ self.assertEqual(0, len(samples))
def test_create(self):
sample = self.mgr.create(**CREATE_SAMPLE)
@@ -200,7 +200,7 @@ class OldSampleManagerTest(utils.BaseTestCase):
samples = list(self.mgr.list(meter_name='instance', limit=1))
expect = ['GET', '/v2/meters/instance?limit=1']
self.http_client.assert_called(*expect)
- self.assertEqual(len(samples), 1)
+ self.assertEqual(1, len(samples))
class SampleManagerTest(utils.BaseTestCase):
diff --git a/ceilometerclient/tests/unit/v2/test_statistics.py b/ceilometerclient/tests/unit/v2/test_statistics.py
index d2f7aee..e41b38c 100644
--- a/ceilometerclient/tests/unit/v2/test_statistics.py
+++ b/ceilometerclient/tests/unit/v2/test_statistics.py
@@ -125,8 +125,8 @@ class StatisticsManagerTest(utils.BaseTestCase):
'GET', '/v2/meters/instance/statistics'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(stats), 1)
- self.assertEqual(stats[0].count, 135)
+ self.assertEqual(1, len(stats))
+ self.assertEqual(135, stats[0].count)
def test_list_by_meter_name_extended(self):
stats = list(self.mgr.list(meter_name='instance',
@@ -140,8 +140,8 @@ class StatisticsManagerTest(utils.BaseTestCase):
'GET', '%s?%s' % (base_url, qry)
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(stats), 1)
- self.assertEqual(stats[0].count, 135)
+ self.assertEqual(1, len(stats))
+ self.assertEqual(135, stats[0].count)
def test_list_by_meter_name_with_period(self):
stats = list(self.mgr.list(meter_name='instance',
@@ -156,8 +156,8 @@ class StatisticsManagerTest(utils.BaseTestCase):
'GET', '%s?%s%s' % (base_url, qry, period)
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(stats), 1)
- self.assertEqual(stats[0].count, 135)
+ self.assertEqual(1, len(stats))
+ self.assertEqual(135, stats[0].count)
def test_list_by_meter_name_with_groupby(self):
stats = list(self.mgr.list(meter_name='instance',
@@ -173,11 +173,11 @@ class StatisticsManagerTest(utils.BaseTestCase):
'%s?%s%s' % (base_url, qry, groupby)
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(stats), 2)
- self.assertEqual(stats[0].count, 135)
- self.assertEqual(stats[1].count, 12)
- self.assertEqual(stats[0].groupby.get('resource_id'), 'foo')
- self.assertEqual(stats[1].groupby.get('resource_id'), 'bar')
+ self.assertEqual(2, len(stats))
+ self.assertEqual(135, stats[0].count)
+ self.assertEqual(12, stats[1].count)
+ self.assertEqual('foo', stats[0].groupby.get('resource_id'))
+ self.assertEqual('bar', stats[1].groupby.get('resource_id'))
def test_list_by_meter_name_with_groupby_as_str(self):
stats = list(self.mgr.list(meter_name='instance',
diff --git a/ceilometerclient/tests/unit/v2/test_trait_descriptions.py b/ceilometerclient/tests/unit/v2/test_trait_descriptions.py
index abe8288..b249d3d 100644
--- a/ceilometerclient/tests/unit/v2/test_trait_descriptions.py
+++ b/ceilometerclient/tests/unit/v2/test_trait_descriptions.py
@@ -46,7 +46,7 @@ class TraitDescriptionManagerTest(utils.BaseTestCase):
'GET', '/v2/event_types/Foo/traits'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(trait_descriptions), 3)
+ self.assertEqual(3, len(trait_descriptions))
for i, vals in enumerate([('trait_1', 'string'),
('trait_2', 'integer'),
('trait_3', 'datetime')]):
diff --git a/ceilometerclient/tests/unit/v2/test_traits.py b/ceilometerclient/tests/unit/v2/test_traits.py
index 7b44a69..e277524 100644
--- a/ceilometerclient/tests/unit/v2/test_traits.py
+++ b/ceilometerclient/tests/unit/v2/test_traits.py
@@ -48,7 +48,7 @@ class TraitManagerTest(utils.BaseTestCase):
'GET', '/v2/event_types/Foo/traits/trait_1'
]
self.http_client.assert_called(*expect)
- self.assertEqual(len(traits), 2)
+ self.assertEqual(2, len(traits))
for i, vals in enumerate([('trait_1',
'datetime',
'2014-01-07T17:22:10.925553'),