libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [3/9] git commit: LIBCLOUD-504: Added support for records with multiple values such as MX/NS records as well an additional fixture and test.
Date Wed, 05 Feb 2014 19:44:59 GMT
LIBCLOUD-504: Added support for records with multiple values such as MX/NS records as well
an additional fixture and test.

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


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

Branch: refs/heads/trunk
Commit: 8fb0473ab9cb59f90c56b0a16960014b658f72bf
Parents: 5e9601f
Author: Chris DeRamus <chris@divvycloud.com>
Authored: Sun Feb 2 08:04:44 2014 -0500
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Wed Feb 5 14:33:12 2014 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/route53.py                 | 17 ++++++++++-----
 .../test/dns/fixtures/route53/list_records.xml  | 23 ++++++++++++++++++++
 libcloud/test/dns/test_route53.py               | 10 ++++++++-
 3 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fb0473a/libcloud/dns/drivers/route53.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/route53.py b/libcloud/dns/drivers/route53.py
index ae128e4..8046bbb 100644
--- a/libcloud/dns/drivers/route53.py
+++ b/libcloud/dns/drivers/route53.py
@@ -289,12 +289,17 @@ class Route53DNSDriver(DNSDriver):
                                                     namespace=NAMESPACE))
         ttl = findtext(element=elem, xpath='TTL', namespace=NAMESPACE)
 
-        # TODO: Support records with multiple values
-        value_elem = elem.findall(
-            fixxpath(xpath='ResourceRecords/ResourceRecord',
-                     namespace=NAMESPACE))[0]
-        data = findtext(element=(value_elem), xpath='Value',
-                        namespace=NAMESPACE)
+        data = ''
+        for record_elem in elem.findall(fixxpath(
+                                        xpath='ResourceRecords/ResourceRecord',
+                                        namespace=NAMESPACE)):
+
+            data += findtext(element=(record_elem),
+                             xpath='Value',
+                             namespace=NAMESPACE) + ' '
+
+        # Strip off the trailing space
+        data = data.rstrip(' ')
 
         extra = {'ttl': ttl}
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fb0473a/libcloud/test/dns/fixtures/route53/list_records.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/route53/list_records.xml b/libcloud/test/dns/fixtures/route53/list_records.xml
index 039272a..ff6a395 100644
--- a/libcloud/test/dns/fixtures/route53/list_records.xml
+++ b/libcloud/test/dns/fixtures/route53/list_records.xml
@@ -35,6 +35,29 @@
          </ResourceRecords>
       </ResourceRecordSet>
 
+      <ResourceRecordSet>
+         <Name>testdomain.com</Name>
+         <Type>MX</Type>
+         <TTL>3600</TTL>
+         <ResourceRecords>
+            <ResourceRecord>
+               <Value>1 ASPMX.L.GOOGLE.COM.</Value>
+            </ResourceRecord>
+            <ResourceRecord>
+               <Value>5 ALT1.ASPMX.L.GOOGLE.COM.</Value>
+            </ResourceRecord>
+            <ResourceRecord>
+               <Value>5 ALT2.ASPMX.L.GOOGLE.COM.</Value>
+            </ResourceRecord>
+            <ResourceRecord>
+               <Value>10 ASPMX2.GOOGLEMAIL.COM.</Value>
+            </ResourceRecord>
+            <ResourceRecord>
+               <Value>10 ASPMX3.GOOGLEMAIL.COM.</Value>
+            </ResourceRecord>
+         </ResourceRecords>
+      </ResourceRecordSet>
+
   </ResourceRecordSets>
 </ListResourceRecordSetsResponse>
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fb0473a/libcloud/test/dns/test_route53.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_route53.py b/libcloud/test/dns/test_route53.py
index 220166e..b5c1cdf 100644
--- a/libcloud/test/dns/test_route53.py
+++ b/libcloud/test/dns/test_route53.py
@@ -50,7 +50,7 @@ class Route53Tests(unittest.TestCase):
     def test_list_records(self):
         zone = self.driver.list_zones()[0]
         records = self.driver.list_records(zone=zone)
-        self.assertEqual(len(records), 3)
+        self.assertEqual(len(records), 4)
 
         record = records[1]
         self.assertEqual(record.name, 'www')
@@ -58,6 +58,14 @@ class Route53Tests(unittest.TestCase):
         self.assertEqual(record.type, RecordType.A)
         self.assertEqual(record.data, '208.111.35.173')
 
+        mx_record = records[3]
+        self.assertEqual(mx_record.type, RecordType.MX)
+        self.assertEqual(mx_record.data, '1 ASPMX.L.GOOGLE.COM. '
+                         '5 ALT1.ASPMX.L.GOOGLE.COM. '
+                         '5 ALT2.ASPMX.L.GOOGLE.COM. '
+                         '10 ASPMX2.GOOGLEMAIL.COM. '
+                         '10 ASPMX3.GOOGLEMAIL.COM.')
+
     def test_get_zone(self):
         zone = self.driver.get_zone(zone_id='47234')
         self.assertEqual(zone.id, '47234')


Mime
View raw message