Make tox.ini tox 4.0.0 compatible/fix gate
* Removed skipsdist=True to make sure placement available in the virtual env. Without this, our entrypoints are not available. * Removed basepython = python3 as we assume all developer switched to python3 in their env already * Removed ignore_basepython_conflict = True as without the basepython definition generative targets now work without conflict See [1] for a similar change made to placement. It is also necessary to fix issues with the gate. For reasons that I have yet to grok, a mock of 'requests.request' used in some test is no longer functioning as expected. My guess is that something is now importing requests before us and interfering with the mock but never mind - we can easily bypass the issue by mocking 'requests.post' instead. [1] https://review.opendev.org/c/openstack/placement/+/868418/ Change-Id: I3b8263afbf0ccee88ceaac2040d5ad274f22d74a Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
2ad28a3a14
commit
626df3a5e9
@ -73,7 +73,7 @@ class EC2TokenMiddlewareTestBase(utils.TestCase):
|
|||||||
|
|
||||||
class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase):
|
class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase):
|
||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
requests, 'request',
|
requests, 'post',
|
||||||
return_value=FakeResponse(EMPTY_RESPONSE, status_code=200))
|
return_value=FakeResponse(EMPTY_RESPONSE, status_code=200))
|
||||||
def test_protocol_old_versions(self, mock_request):
|
def test_protocol_old_versions(self, mock_request):
|
||||||
req = webob.Request.blank('/test')
|
req = webob.Request.blank('/test')
|
||||||
@ -85,9 +85,9 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase):
|
|||||||
self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token'])
|
self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token'])
|
||||||
|
|
||||||
mock_request.assert_called_with(
|
mock_request.assert_called_with(
|
||||||
'POST', 'http://localhost:5000/v3/ec2tokens',
|
'http://localhost:5000/v3/ec2tokens',
|
||||||
data=mock.ANY, headers={'Content-Type': 'application/json'},
|
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'])
|
data = jsonutils.loads(mock_request.call_args[1]['data'])
|
||||||
expected_data = {
|
expected_data = {
|
||||||
@ -104,7 +104,7 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase):
|
|||||||
self.assertDictEqual(expected_data, data)
|
self.assertDictEqual(expected_data, data)
|
||||||
|
|
||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
requests, 'request',
|
requests, 'post',
|
||||||
return_value=FakeResponse(EMPTY_RESPONSE, status_code=200))
|
return_value=FakeResponse(EMPTY_RESPONSE, status_code=200))
|
||||||
def test_protocol_v4(self, mock_request):
|
def test_protocol_v4(self, mock_request):
|
||||||
req = webob.Request.blank('/test')
|
req = webob.Request.blank('/test')
|
||||||
@ -120,9 +120,9 @@ class EC2TokenMiddlewareTestGood(EC2TokenMiddlewareTestBase):
|
|||||||
self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token'])
|
self.assertEqual(TOKEN_ID, req.headers['X-Auth-Token'])
|
||||||
|
|
||||||
mock_request.assert_called_with(
|
mock_request.assert_called_with(
|
||||||
'POST', 'http://localhost:5000/v3/ec2tokens',
|
'http://localhost:5000/v3/ec2tokens',
|
||||||
data=mock.ANY, headers={'Content-Type': 'application/json'},
|
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'])
|
data = jsonutils.loads(mock_request.call_args[1]['data'])
|
||||||
expected_data = {
|
expected_data = {
|
||||||
@ -154,8 +154,8 @@ class EC2TokenMiddlewareTestBad(EC2TokenMiddlewareTestBase):
|
|||||||
resp = req.get_response(self.middleware)
|
resp = req.get_response(self.middleware)
|
||||||
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
||||||
|
|
||||||
@mock.patch.object(requests,
|
@mock.patch.object(
|
||||||
'request',
|
requests, 'post',
|
||||||
return_value=FakeResponse(EMPTY_RESPONSE))
|
return_value=FakeResponse(EMPTY_RESPONSE))
|
||||||
def test_communication_failure(self, mock_request):
|
def test_communication_failure(self, mock_request):
|
||||||
req = webob.Request.blank('/test')
|
req = webob.Request.blank('/test')
|
||||||
@ -163,12 +163,13 @@ class EC2TokenMiddlewareTestBad(EC2TokenMiddlewareTestBase):
|
|||||||
req.GET['AWSAccessKeyId'] = 'test-key-id'
|
req.GET['AWSAccessKeyId'] = 'test-key-id'
|
||||||
resp = req.get_response(self.middleware)
|
resp = req.get_response(self.middleware)
|
||||||
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
||||||
mock_request.assert_called_with('POST', mock.ANY,
|
mock_request.assert_called_with(
|
||||||
|
'http://localhost:5000/v3/ec2tokens',
|
||||||
data=mock.ANY, headers=mock.ANY,
|
data=mock.ANY, headers=mock.ANY,
|
||||||
verify=mock.ANY, cert=mock.ANY)
|
verify=mock.ANY, cert=mock.ANY, timeout=mock.ANY)
|
||||||
|
|
||||||
@mock.patch.object(requests,
|
@mock.patch.object(
|
||||||
'request',
|
requests, 'post',
|
||||||
return_value=FakeResponse(EMPTY_RESPONSE))
|
return_value=FakeResponse(EMPTY_RESPONSE))
|
||||||
def test_no_result_data(self, mock_request):
|
def test_no_result_data(self, mock_request):
|
||||||
req = webob.Request.blank('/test')
|
req = webob.Request.blank('/test')
|
||||||
@ -176,6 +177,7 @@ class EC2TokenMiddlewareTestBad(EC2TokenMiddlewareTestBase):
|
|||||||
req.GET['AWSAccessKeyId'] = 'test-key-id'
|
req.GET['AWSAccessKeyId'] = 'test-key-id'
|
||||||
resp = req.get_response(self.middleware)
|
resp = req.get_response(self.middleware)
|
||||||
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
self._validate_ec2_error(resp, 400, 'AuthFailure')
|
||||||
mock_request.assert_called_with('POST', mock.ANY,
|
mock_request.assert_called_with(
|
||||||
|
'http://localhost:5000/v3/ec2tokens',
|
||||||
data=mock.ANY, headers=mock.ANY,
|
data=mock.ANY, headers=mock.ANY,
|
||||||
verify=mock.ANY, cert=mock.ANY)
|
verify=mock.ANY, cert=mock.ANY, timeout=mock.ANY)
|
||||||
|
10
tox.ini
10
tox.ini
@ -1,8 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 3.18.0
|
minversion = 4.2.0
|
||||||
skipsdist = True
|
envlist = py3,pep8,releasenotes
|
||||||
envlist = py37,pep8,releasenotes
|
|
||||||
ignore_basepython_conflict = True
|
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
@ -13,8 +11,8 @@ deps =
|
|||||||
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = stestr run {posargs}
|
commands =
|
||||||
basepython = python3
|
stestr run {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands =
|
||||||
|
Loading…
Reference in New Issue
Block a user