Merge "Use StrictVersion to compare versions"
This commit is contained in:
commit
a91f2e4623
@ -139,7 +139,7 @@ class VersionNegotiationMixin(object):
|
|||||||
|
|
||||||
negotiated_ver = str(min(StrictVersion(self.os_ironic_api_version),
|
negotiated_ver = str(min(StrictVersion(self.os_ironic_api_version),
|
||||||
StrictVersion(max_ver)))
|
StrictVersion(max_ver)))
|
||||||
if negotiated_ver < min_ver:
|
if StrictVersion(negotiated_ver) < StrictVersion(min_ver):
|
||||||
negotiated_ver = min_ver
|
negotiated_ver = min_ver
|
||||||
# server handles microversions, but doesn't support
|
# server handles microversions, but doesn't support
|
||||||
# the requested version, so try a negotiated version
|
# the requested version, so try a negotiated version
|
||||||
|
@ -183,6 +183,23 @@ class VersionNegotiationMixinTest(utils.BaseTestCase):
|
|||||||
self.assertEqual(1, mock_pvh.call_count)
|
self.assertEqual(1, mock_pvh.call_count)
|
||||||
self.assertEqual(0, mock_save_data.call_count)
|
self.assertEqual(0, mock_save_data.call_count)
|
||||||
|
|
||||||
|
@mock.patch.object(filecache, 'save_data', autospec=True)
|
||||||
|
@mock.patch.object(http.VersionNegotiationMixin, '_parse_version_headers',
|
||||||
|
autospec=True)
|
||||||
|
def test_negotiate_version_strict_version_comparison(self, mock_pvh,
|
||||||
|
mock_save_data):
|
||||||
|
# Test version comparison with StrictVersion
|
||||||
|
max_ver = '1.10'
|
||||||
|
mock_pvh.return_value = ('1.2', max_ver)
|
||||||
|
mock_conn = mock.MagicMock()
|
||||||
|
self.test_object.os_ironic_api_version = '1.10'
|
||||||
|
result = self.test_object.negotiate_version(mock_conn, self.response)
|
||||||
|
self.assertEqual(max_ver, result)
|
||||||
|
self.assertEqual(1, mock_pvh.call_count)
|
||||||
|
host, port = http.get_server(self.test_object.endpoint)
|
||||||
|
mock_save_data.assert_called_once_with(host=host, port=port,
|
||||||
|
data=max_ver)
|
||||||
|
|
||||||
def test_get_server(self):
|
def test_get_server(self):
|
||||||
host = 'ironic-host'
|
host = 'ironic-host'
|
||||||
port = '6385'
|
port = '6385'
|
||||||
|
Loading…
Reference in New Issue
Block a user