HasLength() rewritten to assertEqual()

HasLength() based assertions are re-written to assertEqual() based
assertion to homogenize the test code base.

For example:

assertThat(.., HasLength()) becomes assertEqual(len(),...)

Change-Id: Ia3bf24e34fffe445ff4b0ee61fb7cbc0eb36a57a
Closes-Bug:#1629898
This commit is contained in:
haris tanvir
2016-10-03 21:15:24 +05:00
parent 2642627da6
commit db3b5b30b2
6 changed files with 6 additions and 18 deletions

View File

@@ -14,8 +14,6 @@
# under the License.
import mock
from testtools import matchers
from watcher.common import exception
# from watcher.common import utils as w_utils
from watcher import objects
@@ -58,7 +56,7 @@ class TestActionObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_action]
actions = objects.Action.list(self.context)
self.assertEqual(1, mock_get_list.call_count)
self.assertThat(actions, matchers.HasLength(1))
self.assertEqual(1, len(actions))
self.assertIsInstance(actions[0], objects.Action)
self.assertEqual(self.context, actions[0]._context)

View File

@@ -14,8 +14,6 @@
# under the License.
import mock
from testtools import matchers
from watcher.common import exception
# from watcher.common import utils as w_utils
from watcher import objects
@@ -58,7 +56,7 @@ class TestActionPlanObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_action_plan]
action_plans = objects.ActionPlan.list(self.context)
self.assertEqual(1, mock_get_list.call_count)
self.assertThat(action_plans, matchers.HasLength(1))
self.assertEqual(1, len(action_plans))
self.assertIsInstance(action_plans[0], objects.ActionPlan)
self.assertEqual(self.context, action_plans[0]._context)

View File

@@ -14,8 +14,6 @@
# under the License.
import mock
from testtools import matchers
from watcher.common import exception
# from watcher.common import utils as w_utils
from watcher import objects
@@ -58,7 +56,7 @@ class TestAuditObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_audit]
audits = objects.Audit.list(self.context)
self.assertEqual(1, mock_get_list.call_count, 1)
self.assertThat(audits, matchers.HasLength(1))
self.assertEqual(1, len(audits))
self.assertIsInstance(audits[0], objects.Audit)
self.assertEqual(self.context, audits[0]._context)

View File

@@ -14,8 +14,6 @@
# under the License.
import mock
from testtools import matchers
from watcher.common import exception
# from watcher.common import utils as w_utils
from watcher import objects
@@ -64,7 +62,7 @@ class TestEfficacyIndicatorObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_efficacy_indicator]
efficacy_indicators = objects.EfficacyIndicator.list(self.context)
self.assertEqual(1, mock_get_list.call_count)
self.assertThat(efficacy_indicators, matchers.HasLength(1))
self.assertEqual(1, len(efficacy_indicators))
self.assertIsInstance(
efficacy_indicators[0], objects.EfficacyIndicator)
self.assertEqual(self.context, efficacy_indicators[0]._context)

View File

@@ -14,8 +14,6 @@
# under the License.
import mock
from testtools import matchers
from watcher import objects
from watcher.tests.db import base
from watcher.tests.db import utils
@@ -66,7 +64,7 @@ class TestScoringEngineObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_scoring_engine]
scoring_engines = objects.ScoringEngine.list(self.context)
self.assertEqual(1, mock_get_list.call_count, 1)
self.assertThat(scoring_engines, matchers.HasLength(1))
self.assertEqual(1, len(scoring_engines))
self.assertIsInstance(scoring_engines[0], objects.ScoringEngine)
self.assertEqual(self.context, scoring_engines[0]._context)

View File

@@ -15,8 +15,6 @@
import mock
from testtools import matchers
from watcher.common import exception
from watcher import objects
from watcher.tests.db import base
@@ -58,7 +56,7 @@ class TestStrategyObject(base.DbTestCase):
mock_get_list.return_value = [self.fake_strategy]
strategies = objects.Strategy.list(self.context)
self.assertEqual(1, mock_get_list.call_count, 1)
self.assertThat(strategies, matchers.HasLength(1))
self.assertEqual(1, len(strategies))
self.assertIsInstance(strategies[0], objects.Strategy)
self.assertEqual(self.context, strategies[0]._context)