libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [libcloud] Kami commented on a change in pull request #1323: Add Gandi LiveDNS driver
Date Sun, 28 Jul 2019 09:58:38 GMT
Kami commented on a change in pull request #1323: Add Gandi LiveDNS driver
URL: https://github.com/apache/libcloud/pull/1323#discussion_r307994146
 
 

 ##########
 File path: libcloud/test/dns/test_gandi_live.py
 ##########
 @@ -0,0 +1,174 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+import unittest
+
+from libcloud.utils.py3 import httplib
+from libcloud.dns.types import RecordType
+from libcloud.dns.drivers.gandi_live import GandiLiveDNSDriver
+from libcloud.dns.base import Zone, Record
+from libcloud.test.file_fixtures import DNSFileFixtures
+from libcloud.test.secrets import DNS_GANDI_LIVE
+from libcloud.test.common.test_gandi_live import BaseGandiLiveMockHttp
+
+
+class GandiLiveTests(unittest.TestCase):
+
+    def setUp(self):
+        GandiLiveDNSDriver.connectionCls.conn_class = GandiLiveMockHttp
+        GandiLiveMockHttp.type = None
+        self.driver = GandiLiveDNSDriver(*DNS_GANDI_LIVE)
+        self.test_zone = Zone(id='example.com', type='master', ttl=None,
+                              domain='example.com', extra={'zone_uuid': 'a53re'},
+                              driver=self)
+        self.test_record = Record(id='A:bob', type=RecordType.A,
+                                  name='bob', zone=self.test_zone,
+                                  data='127.0.0.1', driver=self, extra={})
+
+    def test_list_zones(self):
+        zones = self.driver.list_zones()
+        self.assertEqual(len(zones), 2)
+        zone = zones[0]
+        self.assertEqual(zone.id, 'example.com')
+        self.assertEqual(zone.type, 'master')
+        self.assertEqual(zone.domain, 'example.com')
+        self.assertIsNone(zone.ttl)
+        zone = zones[1]
+        self.assertEqual(zone.id, 'example.net')
+        self.assertEqual(zone.type, 'master')
+        self.assertEqual(zone.domain, 'example.net')
+        self.assertIsNone(zone.ttl)
+
+    def test_create_zone(self):
+        zone = self.driver.create_zone('example.org',
+                                       extra={'name': 'Example'})
+        self.assertEqual(zone.id, 'example.org')
+        self.assertEqual(zone.domain, 'example.org')
+
+    def test_get_zone(self):
+        zone = self.driver.get_zone('example.com')
+        self.assertEqual(zone.id, 'example.com')
+        self.assertEqual(zone.type, 'master')
+        self.assertEqual(zone.domain, 'example.com')
+        self.assertIsNone(zone.ttl)
+
+    def test_list_records(self):
+        records = self.driver.list_records(self.test_zone)
+        self.assertEqual(len(records), 3)
+        record = records[0]
+        self.assertEqual(record.id, 'A:@')
+        self.assertEqual(record.name, '@')
+        self.assertEqual(record.type, RecordType.A)
+        self.assertEqual(record.data, ['127.0.0.1'])
 
 Review comment:
   Hm, can single record contain multiple values?
   
   I believe we handle this inside other drivers by creating multiple ``Record`` class instances
(all of them share the same name, but have a different ``value`` which is a string), but I'm
not 100% and I would need to double check.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message