Softlayer driver: Add get_image tests + change exception raised to 
SoftLayerException


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/42317090
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/42317090
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/42317090

Branch: refs/heads/trunk
Commit: 4231709070f073e63f673f612b873e0f7a5c6f7c
Parents: 32d54fd
Author: Francois Regnoult <francois.regno...@wandera.com>
Authored: Thu Aug 3 12:41:15 2017 +0100
Committer: Anthony Shaw <anthonys...@apache.org>
Committed: Fri Aug 11 14:33:43 2017 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/softlayer.py   |  3 ++-
 libcloud/test/compute/test_softlayer.py | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/42317090/libcloud/compute/drivers/softlayer.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/softlayer.py 
b/libcloud/compute/drivers/softlayer.py
index f2b9db1..f5b9b15 100644
--- a/libcloud/compute/drivers/softlayer.py
+++ b/libcloud/compute/drivers/softlayer.py
@@ -447,7 +447,8 @@ class SoftLayerNodeDriver(NodeDriver):
         images = self.list_images()
         images = [image for image in images if image.id == image_id]
         if len(images) < 1:
-            raise LibcloudError('could not find the image with id %s' % 
image_id)
+            raise SoftLayerException('could not find the image with id %s'\
+                                % image_id)
         image = images[0]
         return image
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/42317090/libcloud/test/compute/test_softlayer.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_softlayer.py 
b/libcloud/test/compute/test_softlayer.py
index 72de0df..262b2ab 100644
--- a/libcloud/test/compute/test_softlayer.py
+++ b/libcloud/test/compute/test_softlayer.py
@@ -73,6 +73,16 @@ class SoftLayerTests(unittest.TestCase):
         image = images[0]
         self.assertEqual(image.id, 'CENTOS_6_64')
 
+    def test_get_image(self):
+        image = self.driver.get_image('CENTOS_6_64')
+        self.assertEqual(image.id, 'CENTOS_6_64')
+
+    def test_fail_get_image(self):
+        self.assertRaises(
+            SoftLayerException,
+            self.driver.get_image,
+            'NOT_IMAGE')
+
     def test_list_sizes(self):
         sizes = self.driver.list_sizes()
         self.assertEqual(len(sizes), 13)

Reply via email to