Skip to content

Commit

Permalink
Added testing for guest os features.
Browse files Browse the repository at this point in the history
  • Loading branch information
illfelder committed Jun 29, 2016
1 parent 98e56d6 commit 6fb25b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libcloud/compute/drivers/gce.py
Expand Up @@ -4756,7 +4756,7 @@ def ex_copy_image(self, name, url, description=None, family=None,
:type family: ``str``
:param guest_os_features: The features of the guest operating system.
:type guest_os_features: ``list`` of ``str`` or ``None``
:type guest_os_features: ``list`` of ``dict`` or ``None``
:return: NodeImage object based on provided information or None if an
image with that name is not found.
Expand Down
34 changes: 27 additions & 7 deletions libcloud/test/compute/test_gce.py
Expand Up @@ -15,9 +15,10 @@
"""
Tests for Google Compute Engine Driver
"""
import datetime
import mock
import sys
import unittest
import datetime

from libcloud.utils.py3 import httplib
from libcloud.compute.drivers.gce import (GCENodeDriver, API_VERSION,
Expand Down Expand Up @@ -449,13 +450,32 @@ def test_ex_create_healthcheck(self):

def test_ex_create_image(self):
volume = self.driver.ex_get_volume('lcdisk')
image = self.driver.ex_create_image('coreos', volume)
description = 'CoreOS beta 522.3.0'
name = 'coreos'
family = 'coreos'
guest_os_features = ['VIRTIO_SCSI_MULTIQUEUE']
expected_features = [{'type': 'VIRTIO_SCSI_MULTIQUEUE'}]
mock_request = mock.Mock()
mock_request.side_effect = self.driver.connection.async_request
self.driver.connection.async_request = mock_request

image = self.driver.ex_create_image(
name, volume, description=description, family='coreos',
guest_os_features=guest_os_features)
self.assertTrue(isinstance(image, GCENodeImage))
self.assertTrue(image.name.startswith('coreos'))
self.assertEqual(image.extra['description'], 'CoreOS beta 522.3.0')
self.assertEqual(image.extra['family'], 'coreos')
self.assertEqual(image.extra['guestOsFeatures'],
[{'type': 'VIRTIO_SCSI_MULTIQUEUE'}])
self.assertTrue(image.name.startswith(name))
self.assertEqual(image.extra['description'], description)
self.assertEqual(image.extra['family'], family)
self.assertEqual(image.extra['guestOsFeatures'], expected_features)
expected_data={'description': description,
'family': family,
'guestOsFeatures': expected_features,
'name': name,
'sourceDisk': volume.extra['selfLink'],
'zone': volume.extra['zone'].name}
mock_request.assert_called_once_with('/global/images',
data=expected_data,
method='POST')

def test_ex_create_firewall(self):
firewall_name = 'lcfirewall'
Expand Down

0 comments on commit 6fb25b9

Please sign in to comment.