def test_make_client_version_from_env_no_warning(self, mock_client,
                                                  mock_warning):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     plugin.make_client(instance)
     self.assertFalse(mock_warning.called)
 def test_make_client(self, mock_client, mock_warning):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     plugin.make_client(instance)
     mock_client.assert_called_once_with(os_ironic_api_version='1.6',
                                         session=instance.session,
                                         region_name=instance._region_name,
                                         endpoint='endpoint')
     self.assertFalse(mock_warning.called)
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal', region_name=instance._region_name,
         interface=instance.interface)
 def test_make_client_explicit_version(self, mock_client):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     plugin.make_client(instance)
     mock_client.assert_called_once_with(
         os_ironic_api_version=fakes.API_VERSION,
         allow_api_version_downgrade=False,
         session=instance.session,
         region_name=instance._region_name,
         endpoint_override='endpoint')
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal', region_name=instance._region_name,
         interface=instance.interface)
示例#4
0
 def test_make_client_explicit_version(self, mock_client):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     plugin.make_client(instance)
     mock_client.assert_called_once_with(
         os_ironic_api_version=fakes.API_VERSION,
         allow_api_version_downgrade=False,
         session=instance.session,
         region_name=instance._region_name,
         endpoint_override='endpoint')
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal',
         region_name=instance._region_name,
         interface=instance.interface)
 def test_make_client_log_warning_no_version_specified(self, mock_client,
                                                       mock_warning):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     instance._api_version = {'baremetal': http.DEFAULT_VER}
     plugin.make_client(instance)
     mock_client.assert_called_once_with(
         os_ironic_api_version=http.DEFAULT_VER,
         session=instance.session,
         region_name=instance._region_name,
         endpoint='endpoint')
     self.assertTrue(mock_warning.called)
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal', region_name=instance._region_name,
         interface=instance.interface)
 def test_make_client_latest(self, mock_client):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     instance._api_version = {'baremetal': plugin.LATEST_VERSION}
     plugin.make_client(instance)
     mock_client.assert_called_once_with(
         # NOTE(dtantsur): "latest" is changed to an actual version before
         # make_client is called.
         os_ironic_api_version=plugin.LATEST_VERSION,
         allow_api_version_downgrade=True,
         session=instance.session,
         region_name=instance._region_name,
         endpoint_override='endpoint')
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal', region_name=instance._region_name,
         interface=instance.interface)
示例#7
0
 def test_make_client_latest(self, mock_client):
     instance = fakes.FakeClientManager()
     instance.get_endpoint_for_service_type = mock.Mock(
         return_value='endpoint')
     instance._api_version = {'baremetal': plugin.LATEST_VERSION}
     plugin.make_client(instance)
     mock_client.assert_called_once_with(
         # NOTE(dtantsur): "latest" is changed to an actual version before
         # make_client is called.
         os_ironic_api_version=plugin.LATEST_VERSION,
         allow_api_version_downgrade=True,
         session=instance.session,
         region_name=instance._region_name,
         endpoint_override='endpoint')
     instance.get_endpoint_for_service_type.assert_called_once_with(
         'baremetal',
         region_name=instance._region_name,
         interface=instance.interface)