diff --git a/keystonemiddleware/tests/unit/test_ec2_token_middleware.py b/keystonemiddleware/tests/unit/test_ec2_token_middleware.py index be6a0d16..e04a1e92 100644 --- a/keystonemiddleware/tests/unit/test_ec2_token_middleware.py +++ b/keystonemiddleware/tests/unit/test_ec2_token_middleware.py @@ -73,7 +73,7 @@ class EC2TokenMiddlewareTestBase(utils.TestCase): class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase): @mock.patch.object( - requests, 'request', + requests, 'post', return_value=FakeResponse(EMPTY_RESPONSE, status_code=200)) def test_protocol_old_versions(self, mock_request): req = webob.Request.blank('/test') @@ -85,9 +85,9 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase): self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token']) mock_request.assert_called_with( - 'POST', 'http://localhost:5000/v3/ec2tokens', + 'http://localhost:5000/v3/ec2tokens', data=mock.ANY, headers={'Content-Type': 'application/json'}, - verify=True, cert=None) + verify=True, cert=None, timeout=mock.ANY) data = jsonutils.loads(mock_request.call_args[1]['data']) expected_data = { @@ -104,7 +104,7 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase): self.assertDictEqual(expected_data, data) @mock.patch.object( - requests, 'request', + requests, 'post', return_value=FakeResponse(EMPTY_RESPONSE, status_code=200)) def test_protocol_v4(self, mock_request): req = webob.Request.blank('/test') @@ -120,9 +120,9 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase): self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token']) mock_request.assert_called_with( - 'POST', 'http://localhost:5000/v3/ec2tokens', + 'http://localhost:5000/v3/ec2tokens', data=mock.ANY, headers={'Content-Type': 'application/json'}, - verify=True, cert=None) + verify=True, cert=None, timeout=mock.ANY) data = jsonutils.loads(mock_request.call_args[1]['data']) expected_data = { @@ -154,28 +154,30 @@ class EC2TokenMiddlewareTestBad(EC2TokenMiddlewareTestBase): resp = req.get_response(self.middleware) self._validate_ec2_error(resp, 400, 'AuthFailure') - @mock.patch.object(requests, - 'request', - return_value=FakeResponse(EMPTY_RESPONSE)) + @mock.patch.object( + requests, 'post', + return_value=FakeResponse(EMPTY_RESPONSE)) def test_communication_failure(self, mock_request): req = webob.Request.blank('/test') req.GET['Signature'] = 'test-signature' req.GET['AWSAccessKeyId'] = 'test-key-id' resp = req.get_response(self.middleware) self._validate_ec2_error(resp, 400, 'AuthFailure') - mock_request.assert_called_with('POST', mock.ANY, - data=mock.ANY, headers=mock.ANY, - verify=mock.ANY, cert=mock.ANY) + mock_request.assert_called_with( + 'http://localhost:5000/v3/ec2tokens', + data=mock.ANY, headers=mock.ANY, + verify=mock.ANY, cert=mock.ANY, timeout=mock.ANY) - @mock.patch.object(requests, - 'request', - return_value=FakeResponse(EMPTY_RESPONSE)) + @mock.patch.object( + requests, 'post', + return_value=FakeResponse(EMPTY_RESPONSE)) def test_no_result_data(self, mock_request): req = webob.Request.blank('/test') req.GET['Signature'] = 'test-signature' req.GET['AWSAccessKeyId'] = 'test-key-id' resp = req.get_response(self.middleware) self._validate_ec2_error(resp, 400, 'AuthFailure') - mock_request.assert_called_with('POST', mock.ANY, - data=mock.ANY, headers=mock.ANY, - verify=mock.ANY, cert=mock.ANY) + mock_request.assert_called_with( + 'http://localhost:5000/v3/ec2tokens', + data=mock.ANY, headers=mock.ANY, + verify=mock.ANY, cert=mock.ANY, timeout=mock.ANY) diff --git a/tox.ini b/tox.ini index ab4bee0a..50a5477c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,6 @@ [tox] -minversion = 3.18.0 -skipsdist = True -envlist = py37,pep8,releasenotes -ignore_basepython_conflict = True +minversion = 4.2.0 +envlist = py3,pep8,releasenotes [testenv] usedevelop = True @@ -13,8 +11,8 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = stestr run {posargs} -basepython = python3 +commands = + stestr run {posargs} [testenv:pep8] commands =