Remove last usages of flexmock
Change-Id: I4993bea250b96cc4f8fadabf03349ac9fcb6271a
This commit is contained in:
parent
53812aeb40
commit
c024e7061c
@ -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)
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -1,4 +1,3 @@
|
||||
flexmock==0.9.4
|
||||
mongomock==2.0.0
|
||||
nose # LGPL
|
||||
setuptools>=16.0,!=24.0.0 # PSF/ZPL
|
||||
|
Loading…
x
Reference in New Issue
Block a user