From 3c450f57dbbd4cba021459b91e4656d58162a832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Albert?= Date: Fri, 24 Jul 2015 14:53:21 +0200 Subject: [PATCH] Fixed mock tests failing due to deprecation Some assert methods have been removed from mock. We've transitioned to new methods. Change-Id: Icdee669b26d0e8086f400c43deab384b64d0fd6b --- cloudkitty/tests/test_hashmap.py | 4 ++-- cloudkitty/tests/test_keystone_fetcher.py | 7 ++++++- cloudkitty/tests/test_orchestrator.py | 4 +++- cloudkitty/tests/test_utils.py | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cloudkitty/tests/test_hashmap.py b/cloudkitty/tests/test_hashmap.py index 42d64ade..ace49f3d 100644 --- a/cloudkitty/tests/test_hashmap.py +++ b/cloudkitty/tests/test_hashmap.py @@ -96,7 +96,7 @@ class HashMapRatingTest(tests.TestCase): self._db_api.create_group('test_group') groups = self._db_api.list_groups() self.assertEqual([FAKE_UUID], groups) - patch_generate_uuid.assert_called_once() + patch_generate_uuid.assert_called_once_with() def test_create_duplicate_group(self): self._db_api.create_group('test_group') @@ -213,7 +213,7 @@ class HashMapRatingTest(tests.TestCase): self._db_api.create_service('compute') services = self._db_api.list_services() self.assertEqual([FAKE_UUID], services) - patch_generate_uuid.assert_called_once() + patch_generate_uuid.assert_called_once_with() def test_create_duplicate_service(self): self._db_api.create_service('compute') diff --git a/cloudkitty/tests/test_keystone_fetcher.py b/cloudkitty/tests/test_keystone_fetcher.py index 015af7c6..08986622 100644 --- a/cloudkitty/tests/test_keystone_fetcher.py +++ b/cloudkitty/tests/test_keystone_fetcher.py @@ -84,6 +84,11 @@ class KeystoneFetcherTest(tests.TestCase): with mock.patch(kclient) as kclientmock: kclientmock.return_value = Client() fetcher = keystone.KeystoneFetcher() - kclientmock.assertCalled() + kclientmock.assert_called_once_with( + auth_url='http://127.0.0.1:5000/v2.0', + username='cloudkitty', + password='cloudkitty', + tenant_name='cloudkitty', + region_name='RegionOne') tenants = fetcher.get_tenants() self.assertEqual(['f266f30b11f246b589fd266f85eeec39'], tenants) diff --git a/cloudkitty/tests/test_orchestrator.py b/cloudkitty/tests/test_orchestrator.py index 69373a41..191e2dc6 100644 --- a/cloudkitty/tests/test_orchestrator.py +++ b/cloudkitty/tests/test_orchestrator.py @@ -86,7 +86,9 @@ class OrchestratorTest(tests.TestCase): 'cloudkitty.rating.processors') stevemock.return_value = fake_mgr worker = orchestrator.BaseWorker() - stevemock.assertCalled() + stevemock.assert_called_once_with( + 'cloudkitty.rating.processors', + invoke_kwds={'tenant_id': None}) self.assertEqual('fake1', worker._processors[0].name) self.assertEqual(3, worker._processors[0].obj.priority) self.assertEqual('fake3', worker._processors[1].name) diff --git a/cloudkitty/tests/test_utils.py b/cloudkitty/tests/test_utils.py index dee6861f..73def825 100644 --- a/cloudkitty/tests/test_utils.py +++ b/cloudkitty/tests/test_utils.py @@ -70,7 +70,7 @@ class UtilsTimeCalculationsTest(unittest.TestCase): date = datetime.datetime(2014, 1, 1) trans_dt = ck_utils.get_month_start() self.assertEqual(date, trans_dt) - patch_utcnow_mock.assert_called_once() + patch_utcnow_mock.assert_called_once_with() @mock.patch.object(ck_utils, 'utcnow', return_value=iso2dt('2014-01-15T00:00:00Z')) @@ -78,7 +78,7 @@ class UtilsTimeCalculationsTest(unittest.TestCase): date = datetime.datetime(2014, 1, 31) trans_dt = ck_utils.get_month_end() self.assertEqual(date, trans_dt) - patch_utcnow_mock.assert_called_once() + patch_utcnow_mock.assert_called_once_with() @mock.patch.object(ck_utils, 'utcnow', return_value=iso2dt('2014-01-31T00:00:00Z')) @@ -86,7 +86,7 @@ class UtilsTimeCalculationsTest(unittest.TestCase): date = datetime.datetime(2013, 12, 1) trans_dt = ck_utils.get_last_month() self.assertEqual(date, trans_dt) - patch_utcnow_mock.assert_called_once() + patch_utcnow_mock.assert_called_once_with() @mock.patch.object(ck_utils, 'utcnow', return_value=iso2dt('2014-01-31T00:00:00Z')) @@ -94,7 +94,7 @@ class UtilsTimeCalculationsTest(unittest.TestCase): date = datetime.datetime(2014, 2, 1) trans_dt = ck_utils.get_next_month() self.assertEqual(date, trans_dt) - patch_utcnow_mock.assert_called_once() + patch_utcnow_mock.assert_called_once_with() def test_get_last_month_leap(self): base_date = datetime.datetime(2016, 3, 31)