You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2022/01/28 21:46:20 UTC

[libcloud] 02/02: Add test which verifies the code doesn't throw if creationDate attribute is not present.

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit d918c5ab2e58dd882ab66f2123f6621129fb918b
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Jan 28 22:30:55 2022 +0100

    Add test which verifies the code doesn't throw if creationDate attribute
    is not present.
---
 .../test/compute/fixtures/ec2/describe_images.xml  | 31 ++++++++++++++++++++++
 libcloud/test/compute/test_ec2.py                  |  9 +++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/compute/fixtures/ec2/describe_images.xml b/libcloud/test/compute/fixtures/ec2/describe_images.xml
index 07e9fa3..650fb91 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_images.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_images.xml
@@ -70,5 +70,36 @@
             <hypervisor>xen</hypervisor>
             <creationDate>2021-01-10T18:25:00.000Z</creationDate>
         </item>
+        <item>
+            <imageId>ami-85b2a8ac</imageId>
+            <imageLocation>123456788908/Test Image 3</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>123456788908</imageOwnerId>
+            <isPublic>false</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-88aa75e1</kernelId>
+            <name>Test Image 3</name>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <billingProducts>
+                <item>
+                    <billingProduct>as-6dr90319</billingProduct>
+                </item>
+            </billingProducts>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-c0bfbbdb</snapshotId>
+                        <volumeSize>20</volumeSize>
+                        <deleteOnTermination>false</deleteOnTermination>
+                        <volumeType>standard</volumeType>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>paravirtual</virtualizationType>
+            <hypervisor>xen</hypervisor>
+        </item>
     </imagesSet>
 </DescribeImagesResponse>
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 6dd47d4..8b8569b 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -574,7 +574,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
     def test_list_images(self):
         images = self.driver.list_images()
 
-        self.assertEqual(len(images), 2)
+        self.assertEqual(len(images), 3)
         location = "123456788908/Test Image"
         self.assertEqual(images[0].id, "ami-57ba933a")
         self.assertEqual(images[0].name, "Test Image")
@@ -598,6 +598,11 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(size, 20)
         self.assertIsInstance(images[1].extra["creation_date"], datetime)
 
+        self.assertEqual(images[2].id, "ami-85b2a8ac")
+        self.assertEqual(images[2].name, "Test Image 3")
+        self.assertEqual(size, 20)
+        self.assertIsNone(images[2].extra["creation_date"])
+
     def test_list_images_with_image_ids(self):
         EC2MockHttp.type = "ex_imageids"
         images = self.driver.list_images(ex_image_ids=["ami-57ba933a"])
@@ -608,7 +613,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
     def test_list_images_with_executable_by(self):
         images = self.driver.list_images(ex_executableby="self")
 
-        self.assertEqual(len(images), 2)
+        self.assertEqual(len(images), 3)
 
     def test_get_image(self):
         image = self.driver.get_image("ami-57ba933a")