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 2014/01/18 01:49:45 UTC

[3/6] git commit: Update Zerigo DNS driver to set Record.name attribute for records for bare domains to None instead of an empty string.

Update Zerigo DNS driver to set Record.name attribute for records for bare
domains to None instead of an empty string.


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

Branch: refs/heads/trunk
Commit: 0df3b71b0c4a5bca67460e05db5908d4dc5089f1
Parents: 81028e6
Author: Tomaz Muraus <to...@apache.org>
Authored: Sat Jan 18 01:30:53 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Jan 18 01:30:53 2014 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/zerigo.py                  |  3 +++
 .../test/dns/fixtures/zerigo/list_records.xml   | 26 ++++++++++++++++++++
 libcloud/test/dns/test_zerigo.py                | 10 +++++++-
 3 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0df3b71b/libcloud/dns/drivers/zerigo.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/zerigo.py b/libcloud/dns/drivers/zerigo.py
index db2ef07..50e3ed0 100644
--- a/libcloud/dns/drivers/zerigo.py
+++ b/libcloud/dns/drivers/zerigo.py
@@ -425,6 +425,9 @@ class ZerigoDNSDriver(DNSDriver):
         priority = findtext(element=elem, xpath='priority', no_text_value=None)
         ttl = findtext(element=elem, xpath='ttl', no_text_value=None)
 
+        if not name:
+            name = None
+
         if ttl:
             ttl = int(ttl)
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0df3b71b/libcloud/test/dns/fixtures/zerigo/list_records.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/zerigo/list_records.xml b/libcloud/test/dns/fixtures/zerigo/list_records.xml
index f0826cf..f226162 100644
--- a/libcloud/test/dns/fixtures/zerigo/list_records.xml
+++ b/libcloud/test/dns/fixtures/zerigo/list_records.xml
@@ -25,4 +25,30 @@
     <updated-at type="datetime">2008-12-07T02:51:13Z</updated-at>
     <zone-id type="integer">12345678</zone-id>
   </host>
+  <host>
+    <created-at type="datetime">2008-12-07T02:51:13Z</created-at>
+    <data>172.16.16.3</data>
+    <fqdn>test2.example.com</fqdn>
+    <host-type>A</host-type>
+    <hostname></hostname>
+    <id type="integer">23456789</id>
+    <notes nil="true"/>
+    <priority type="integer" nil="true"/>
+    <ttl type="integer">3600</ttl>
+    <updated-at type="datetime">2008-12-07T02:51:13Z</updated-at>
+    <zone-id type="integer">12345678</zone-id>
+  </host>
+  <host>
+    <created-at type="datetime">2008-12-07T02:51:13Z</created-at>
+    <data>172.16.16.4</data>
+    <fqdn>test4.example.com</fqdn>
+    <host-type>A</host-type>
+    <id type="integer">23456789</id>
+    <notes nil="true"/>
+    <priority type="integer" nil="true"/>
+    <ttl type="integer">3600</ttl>
+    <updated-at type="datetime">2008-12-07T02:51:13Z</updated-at>
+    <zone-id type="integer">12345678</zone-id>
+  </host>
+
 </hosts>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0df3b71b/libcloud/test/dns/test_zerigo.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_zerigo.py b/libcloud/test/dns/test_zerigo.py
index f74d1ec..7897c00 100644
--- a/libcloud/test/dns/test_zerigo.py
+++ b/libcloud/test/dns/test_zerigo.py
@@ -65,7 +65,7 @@ class ZerigoTests(unittest.TestCase):
         zone = self.driver.list_zones()[0]
         records = list(self.driver.list_records(zone=zone))
 
-        self.assertEqual(len(records), 2)
+        self.assertEqual(len(records), 4)
         self.assertEqual(records[0].name, 'www')
         self.assertEqual(records[0].type, RecordType.A)
         self.assertEqual(records[0].data, '172.16.16.1')
@@ -76,6 +76,14 @@ class ZerigoTests(unittest.TestCase):
         self.assertEqual(records[1].name, 'test')
         self.assertEqual(records[1].extra['ttl'], 3600)
 
+    def test_record_with_empty_name(self):
+        zone = self.driver.list_zones()[0]
+        record1 = list(self.driver.list_records(zone=zone))[-1]
+        record2 = list(self.driver.list_records(zone=zone))[-2]
+
+        self.assertEqual(record1.name, None)
+        self.assertEqual(record2.name, None)
+
     def test_list_records_no_results(self):
         zone = self.driver.list_zones()[0]
         ZerigoMockHttp.type = 'NO_RESULTS'