From c024e7061ccd1d1bde275f9ddf51f2fb27da146b Mon Sep 17 00:00:00 2001 From: Paul Millette Date: Fri, 13 Jan 2017 10:25:02 -0500 Subject: [PATCH] Remove last usages of flexmock Change-Id: I4993bea250b96cc4f8fadabf03349ac9fcb6271a --- almanach/tests/unit/api/v1/base_api.py | 12 +----------- .../tests/unit/api/v1/test_api_authentication.py | 3 ++- almanach/tests/unit/api/v1/test_api_entity.py | 4 ++-- almanach/tests/unit/base.py | 3 --- test-requirements.txt | 1 - 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/almanach/tests/unit/api/v1/base_api.py b/almanach/tests/unit/api/v1/base_api.py index 19250bb..54c346f 100644 --- a/almanach/tests/unit/api/v1/base_api.py +++ b/almanach/tests/unit/api/v1/base_api.py @@ -14,12 +14,10 @@ from datetime import datetime import flask -from flexmock import flexmock from mock import mock from oslo_serialization import jsonutils as json from almanach.api.v1 import routes -from almanach.core import exception from almanach.tests.unit import base @@ -28,7 +26,6 @@ class BaseApi(base.BaseTestCase): def setUp(self): super(BaseApi, self).setUp() self.prepare() - self.prepare_with_successful_authentication() def prepare(self): self.instance_ctl = mock.Mock() @@ -36,7 +33,7 @@ class BaseApi(base.BaseTestCase): self.volume_type_ctl = mock.Mock() self.entity_ctl = mock.Mock() self.app_ctl = mock.Mock() - self.auth_adapter = flexmock() + self.auth_adapter = mock.Mock() routes.instance_ctl = self.instance_ctl routes.volume_ctl = self.volume_ctl routes.volume_type_ctl = self.volume_type_ctl @@ -47,13 +44,6 @@ class BaseApi(base.BaseTestCase): self.app = flask.Flask("almanach") self.app.register_blueprint(routes.api) - def prepare_with_successful_authentication(self): - self.auth_adapter.should_receive("validate").and_return(True) - - def prepare_with_failed_authentication(self): - self.auth_adapter.should_receive("validate")\ - .and_raise(exception.AuthenticationFailureException("Wrong credentials")) - def api_get(self, url, query_string=None, headers=None, accept='application/json'): return self._api_call(url, "get", None, query_string, headers, accept) diff --git a/almanach/tests/unit/api/v1/test_api_authentication.py b/almanach/tests/unit/api/v1/test_api_authentication.py index 3bc4966..241c2cd 100644 --- a/almanach/tests/unit/api/v1/test_api_authentication.py +++ b/almanach/tests/unit/api/v1/test_api_authentication.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from almanach.core import exception from almanach.tests.unit.api.v1 import base_api @@ -20,9 +21,9 @@ class TestApiAuthentication(base_api.BaseApi): def setUp(self): super(TestApiAuthentication, self).setUp() self.prepare() - self.prepare_with_failed_authentication() def test_with_wrong_authentication(self): + self.auth_adapter.validate.side_effect = exception.AuthenticationFailureException('Unauthorized') query_string = {'start': '2014-01-01 00:00:00.0000', 'end': '2014-02-01 00:00:00.0000'} code, result = self.api_get(url='/project/TENANT_ID/entities', diff --git a/almanach/tests/unit/api/v1/test_api_entity.py b/almanach/tests/unit/api/v1/test_api_entity.py index 57550c3..c7af136 100644 --- a/almanach/tests/unit/api/v1/test_api_entity.py +++ b/almanach/tests/unit/api/v1/test_api_entity.py @@ -127,12 +127,12 @@ class TestApiEntity(base_api.BaseApi): self.assertEqual(code, 400) def test_entity_head_with_existing_entity(self): + self.entity_ctl.entity_exists.return_value = True entity_id = "entity_id" - self.entity_ctl.should_receive('entity_exists') \ - .and_return(True) code, result = self.api_head('/entity/{id}'.format(id=entity_id), headers={'X-Auth-Token': 'some token value'}) + self.entity_ctl.entity_exists.assert_called_once_with(entity_id=entity_id) self.assertEqual(code, 200) def test_entity_head_with_nonexistent_entity(self): diff --git a/almanach/tests/unit/base.py b/almanach/tests/unit/base.py index b777c7a..15bc8ad 100644 --- a/almanach/tests/unit/base.py +++ b/almanach/tests/unit/base.py @@ -24,6 +24,3 @@ class BaseTestCase(testtools.TestCase): super(BaseTestCase, self).setUp() self.config_fixture = self.useFixture(fixture.Config(conf=opts.CONF)) self.config = self.config_fixture.conf - - def tearDown(self): - super(BaseTestCase, self).tearDown() diff --git a/test-requirements.txt b/test-requirements.txt index e35507e..d257e6c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,3 @@ -flexmock==0.9.4 mongomock==2.0.0 nose # LGPL setuptools>=16.0,!=24.0.0 # PSF/ZPL