libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [03/13] libcloud git commit: More tests and support for fetching legal agreements.
Date Fri, 27 Nov 2015 06:31:03 GMT
More tests and support for fetching legal agreements.

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>


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

Branch: refs/heads/trunk
Commit: 0af6df0b5645fa626365e7e31e1bda44e1ce89f7
Parents: a3d1103
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Fri Nov 27 14:47:30 2015 +1100
Committer: Anthony Shaw <anthony.p.shaw@gmail.com>
Committed: Fri Nov 27 17:30:11 2015 +1100

----------------------------------------------------------------------
 libcloud/dns/drivers/godaddy.py                 | 36 ++++++++
 .../dns/fixtures/godaddy/purchase_request.json  | 88 ++++++++++++++++++++
 .../fixtures/godaddy/v1_domains_agreements.json |  8 ++
 .../fixtures/godaddy/v1_domains_purchase.json   |  6 ++
 libcloud/test/dns/test_godaddy.py               | 42 ++++++++++
 5 files changed, 180 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0af6df0b/libcloud/dns/drivers/godaddy.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/godaddy.py b/libcloud/dns/drivers/godaddy.py
index 55587ab..730c9b1 100644
--- a/libcloud/dns/drivers/godaddy.py
+++ b/libcloud/dns/drivers/godaddy.py
@@ -438,6 +438,34 @@ class GoDaddyDNSDriver(DNSDriver):
         ).object
         return result
 
+    def ex_get_agreements(self, tld, privacy=True):
+        """
+        Get the legal agreements for a tld
+        Use this in conjunction with ex_purchase_domain
+
+        :param   tld: The top level domain e.g com, eu, uk
+        :type    tld: `str`
+
+        :rtype: `dict` the JSON Schema
+        """
+        result = self.connection.request(
+            '/v1/domains/agreements',
+            params={
+                'tlds':tld,
+                'privacy':str(privacy)
+            },
+            method='GET'
+        ).object
+        agreements = []
+        for item in result:
+            agreements.append(
+                GoDaddyLegalAgreement(
+                    agreement_key=item['agreementKey'],
+                    title=item['title'],
+                    url=item['url'],
+                    content=item['content']))
+        return agreements
+
     def ex_purchase_domain(self, purchase_request):
         """
         Purchase a domain with GoDaddy
@@ -483,3 +511,11 @@ class GoDaddyDomainPurchaseResponse(object):
         self.item_count = item_count
         self.total = total
         self.current = currency
+
+
+class GoDaddyLegalAgreement(object):
+    def __init__(self, agreement_key, title, url, content):
+        self.agreement_key = agreement_key
+        self.title = title
+        self.url = url
+        self.content = content

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0af6df0b/libcloud/test/dns/fixtures/godaddy/purchase_request.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/godaddy/purchase_request.json b/libcloud/test/dns/fixtures/godaddy/purchase_request.json
new file mode 100644
index 0000000..cd7533b
--- /dev/null
+++ b/libcloud/test/dns/fixtures/godaddy/purchase_request.json
@@ -0,0 +1,88 @@
+{
+  "domain": " ",
+  "consent": {
+    "agreementKeys": [
+      " "
+    ],
+    "agreedBy": " ",
+    "agreedAt": " "
+  },
+  "period": 1,
+  "nameServers": [
+    " "
+  ],
+  "renewAuto": true,
+  "privacy": false,
+  "contactRegistrant": {
+    "nameFirst": " ",
+    "nameMiddle": " ",
+    "nameLast": " ",
+    "organization": " ",
+    "jobTitle": " ",
+    "email": " ",
+    "phone": " ",
+    "fax": " ",
+    "addressMailing": {
+      "address1": " ",
+      "address2": " ",
+      "city": " ",
+      "state": " ",
+      "postalCode": " ",
+      "country": "US"
+    }
+  },
+  "contactAdmin": {
+    "nameFirst": " ",
+    "nameMiddle": " ",
+    "nameLast": " ",
+    "organization": " ",
+    "jobTitle": " ",
+    "email": " ",
+    "phone": " ",
+    "fax": " ",
+    "addressMailing": {
+      "address1": " ",
+      "address2": " ",
+      "city": " ",
+      "state": " ",
+      "postalCode": " ",
+      "country": "US"
+    }
+  },
+  "contactTech": {
+    "nameFirst": " ",
+    "nameMiddle": " ",
+    "nameLast": " ",
+    "organization": " ",
+    "jobTitle": " ",
+    "email": " ",
+    "phone": " ",
+    "fax": " ",
+    "addressMailing": {
+      "address1": " ",
+      "address2": " ",
+      "city": " ",
+      "state": " ",
+      "postalCode": " ",
+      "country": "US"
+    }
+  },
+  "contactBilling": {
+    "nameFirst": " ",
+    "nameMiddle": " ",
+    "nameLast": " ",
+    "organization": " ",
+    "jobTitle": " ",
+    "email": " ",
+    "phone": " ",
+    "fax": " ",
+    "addressMailing": {
+      "address1": " ",
+      "address2": " ",
+      "city": " ",
+      "state": " ",
+      "postalCode": " ",
+      "country": "US"
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0af6df0b/libcloud/test/dns/fixtures/godaddy/v1_domains_agreements.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/godaddy/v1_domains_agreements.json b/libcloud/test/dns/fixtures/godaddy/v1_domains_agreements.json
new file mode 100644
index 0000000..15f964b
--- /dev/null
+++ b/libcloud/test/dns/fixtures/godaddy/v1_domains_agreements.json
@@ -0,0 +1,8 @@
+[
+  {
+    "agreementKey": "DNRA",
+    "title": "Domain Name Registration Agreement",
+    "url": "http://www.secureserver.net/agreements/ShowDoc.aspx?pageid=7959&pl_id=1",
+    "content": "<html>\n<head>\n<title>Domain Name Registration and Customer
Service Agreement</title>\n<style type="
+  }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0af6df0b/libcloud/test/dns/fixtures/godaddy/v1_domains_purchase.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/godaddy/v1_domains_purchase.json b/libcloud/test/dns/fixtures/godaddy/v1_domains_purchase.json
new file mode 100644
index 0000000..841c74a
--- /dev/null
+++ b/libcloud/test/dns/fixtures/godaddy/v1_domains_purchase.json
@@ -0,0 +1,6 @@
+{
+  "orderId": 1,
+  "itemCount": 1,
+  "total": 1,
+  "currency": "USD"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0af6df0b/libcloud/test/dns/test_godaddy.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_godaddy.py b/libcloud/test/dns/test_godaddy.py
index 5aaa648..76360b1 100644
--- a/libcloud/test/dns/test_godaddy.py
+++ b/libcloud/test/dns/test_godaddy.py
@@ -59,6 +59,17 @@ class GoDaddyTests(unittest.TestCase):
         self.assertEqual(schema['id'],
                          'https://api.godaddy.com/DomainPurchase#')
 
+    def test_ex_get_agreements(self):
+        ags = self.driver.ex_get_agreements('com')
+        self.assertEqual(len(ags), 1)
+        self.assertEqual(ags[0].title, 'Domain Name Registration Agreement')
+
+    def test_ex_purchase_domain(self):
+        fixtures = DNSFileFixtures('godaddy')
+        document = fixtures.load('purchase_request.json')
+        order = self.driver.ex_purchase_domain(document)
+        self.assertEqual(order.order_id, 1)
+
     def test_list_records(self):
         zone = Zone(id='177184419',
                     domain='aperture-platform.com',
@@ -98,11 +109,34 @@ class GoDaddyTests(unittest.TestCase):
         self.assertEqual(record.type, RecordType.A)
         self.assertEqual(record.data, '50.63.202.42')
 
+    def test_update_record(self):
+        record = self.driver.get_record(
+            'aperture-platform.com',
+            'www:A')
+        record = self.driver.update_record(
+            record=record,
+            name='www',
+            type=RecordType.A,
+            data='50.63.202.22'
+        )
+        self.assertEqual(record.id, 'www:A')
+        self.assertEqual(record.name, 'www')
+        self.assertEqual(record.type, RecordType.A)
+        self.assertEqual(record.data, '50.63.202.22')
+
     def test_get_zone(self):
         zone = self.driver.get_zone('aperture-platform.com')
         self.assertEqual(zone.id, '177184419')
         self.assertEqual(zone.domain, 'aperture-platform.com')
 
+    def test_delete_zone(self):
+        zone = Zone(id='177184419',
+                    domain='aperture-platform.com',
+                    type='master',
+                    ttl=None,
+                    driver=self.driver)
+        self.driver.delete_zone(zone)
+
 
 class GoDaddyMockHttp(MockHttp):
     fixtures = DNSFileFixtures('godaddy')
@@ -135,5 +169,13 @@ class GoDaddyMockHttp(MockHttp):
         body = self.fixtures.load('v1_domains_purchase_schema_com.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _v1_domains_agreements(self, method, url, body, headers):
+        body = self.fixtures.load('v1_domains_agreements.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _v1_domains_purchase(self, method, url, body, headers):
+        body = self.fixtures.load('v1_domains_purchase.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message