Esempio n. 1
0
    def test_get_current_with_http_client(self, mock_list,
                                          mock_is_session_client):
        current_version = versions.Version(
            None, {"links": [{
                "href": "http://nova-api:8774/v2.1"
            }]},
            loaded=True)

        mock_list.return_value = [
            versions.Version(None, {"links": [{
                "href": "http://url/v1"
            }]},
                             loaded=True),
            versions.Version(None, {"links": [{
                "href": "http://url/v2"
            }]},
                             loaded=True),
            versions.Version(None, {"links": [{
                "href": "http://url/v3"
            }]},
                             loaded=True), current_version,
            versions.Version(None, {"links": [{
                "href": "http://url/v21"
            }]},
                             loaded=True)
        ]
        self.assertEqual(current_version, self.cs.versions.get_current())
    def test_server_without_microversion_and_no_version_field(self):
        fake_client = mock.MagicMock()
        fake_client.versions.get_current.return_value = versions.Version(
            None, {})
        novaclient.API_MAX_VERSION = api_versions.APIVersion("2.11")
        novaclient.API_MIN_VERSION = api_versions.APIVersion("2.1")

        self.assertEqual(
            "2.0",
            api_versions.discover_version(
                fake_client, api_versions.APIVersion('2.latest')).get_string())
Esempio n. 3
0
    def test_get_current_with_http_client(self, mock_list,
                                          mock_is_session_client):
        headers = {'x-openstack-request-id': fakes.FAKE_REQUEST_ID}
        resp = utils.TestResponse({"headers": headers})
        current_version = versions.Version(
            None, {"links": [{"href": "http://nova-api:8774/v2.1"}]},
            loaded=True)

        all_versions = [
            versions.Version(
                None, {"links": [{"href": "http://url/v1"}]}, loaded=True),
            versions.Version(
                None, {"links": [{"href": "http://url/v2"}]}, loaded=True),
            versions.Version(
                None, {"links": [{"href": "http://url/v3"}]}, loaded=True),
            current_version,
            versions.Version(
                None, {"links": [{"href": "http://url/v21"}]}, loaded=True)]
        mock_list.return_value = base.ListWithMeta(all_versions, resp)
        v = self.cs.versions.get_current()
        self.assert_request_id(v, fakes.FAKE_REQUEST_ID_LIST)
        self.assertEqual(current_version, v)