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:
Stephen Finucane 2023-06-27 17:16:47 +01:00
parent 2ad28a3a14
commit 626df3a5e9
2 changed files with 24 additions and 24 deletions

View File

@ -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)

10
tox.ini
View File

@ -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 =