def testCreateInstance_SuccessWithWarning(self):
    mock_api = MagicMock(name='Mock Google Client API')
    self.gce_api.GetApi = MagicMock(return_value=mock_api)
    mock_api.instances.return_value.insert.return_value.execute.return_value = {
        'name': 'instance-name',
        'warnings': [
            {
                'code': 'some warning code',
                'message': 'some warning message'
            }
        ]
    }

    self.assertTrue(self.gce_api.CreateInstance(
        'instance-name', 'machine-type', 'image-name'))

    self.assertEqual(1, self.gce_api.GetApi.call_count)
    mock_api.instances.return_value.insert.assert_called_once_with(
        project='project-name', zone='zone-name', body=mock.ANY)
    (mock_api.instances.return_value.insert.return_value.execute.
     assert_called_once_with())
Unit test of CreateInstance() with warning.
dataset/ETHPy150Open GoogleCloudPlatform/Solutions-Using-ETL-tool-on-Google-Compute-Engine/gce_api_test.py/GceApiTest.testCreateInstance_SuccessWithWarning