summaryrefslogtreecommitdiff
path: root/ironicclient/tests/unit/common/test_http.py
diff options
context:
space:
mode:
authorJulia Kreger <juliaashleykreger@gmail.com>2018-01-02 21:46:59 -0800
committerJulia Kreger <juliaashleykreger@gmail.com>2018-01-18 21:27:08 -0800
commit5b01c8f2badb3c4affa4bbb08dd143dbd94f89d4 (patch)
tree88c4061b02514f7ef14d11add4dbe695fc0cd90e /ironicclient/tests/unit/common/test_http.py
parenta91f2e4623057a05d402cd4dfe46cd169f2d8a78 (diff)
downloadpython-ironicclient-5b01c8f2badb3c4affa4bbb08dd143dbd94f89d4.tar.gz
Facilitate latest Rest API use
In order to provide insight into the remote API verison, we need the ability to negotiate upon the latest API version available, and then report what that version is. In order to understand if this has occured, we also need to provide insight into if version negotiation has occured. Adds logic to the session/http clients to faciltate version negotiation on the latest available version, and provide user insight into that verison. Change-Id: I813237eee4b122211f95558f677b25e0675569d5 Related-Bug: #1739440 Related-Bug: #1671145
Diffstat (limited to 'ironicclient/tests/unit/common/test_http.py')
-rw-r--r--ironicclient/tests/unit/common/test_http.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ironicclient/tests/unit/common/test_http.py b/ironicclient/tests/unit/common/test_http.py
index 3ac0269..fffc9db 100644
--- a/ironicclient/tests/unit/common/test_http.py
+++ b/ironicclient/tests/unit/common/test_http.py
@@ -200,6 +200,29 @@ class VersionNegotiationMixinTest(utils.BaseTestCase):
mock_save_data.assert_called_once_with(host=host, port=port,
data=max_ver)
+ @mock.patch.object(filecache, 'save_data', autospec=True)
+ @mock.patch.object(http.VersionNegotiationMixin, '_make_simple_request',
+ autospec=True)
+ @mock.patch.object(http.VersionNegotiationMixin, '_parse_version_headers',
+ autospec=True)
+ def test_negotiate_version_server_user_latest(
+ self, mock_pvh, mock_msr, mock_save_data):
+ # have to retry with simple get
+ mock_pvh.side_effect = iter([(None, None), ('1.1', '1.99')])
+ mock_conn = mock.MagicMock()
+ self.test_object.api_version_select_state = 'user'
+ self.test_object.os_ironic_api_version = 'latest'
+ result = self.test_object.negotiate_version(mock_conn, None)
+ self.assertEqual(http.LATEST_VERSION, result)
+ self.assertEqual('negotiated',
+ self.test_object.api_version_select_state)
+ self.assertEqual(http.LATEST_VERSION,
+ self.test_object.os_ironic_api_version)
+
+ self.assertTrue(mock_msr.called)
+ self.assertEqual(2, mock_pvh.call_count)
+ self.assertEqual(1, mock_save_data.call_count)
+
def test_get_server(self):
host = 'ironic-host'
port = '6385'