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 2020/11/05 22:28:55 UTC

[libcloud] 02/05: Assert that requests contain bodies.

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 8837ee72cd2202febc1589edc16fb8e85c4fcdfe
Author: Andrew Starr-Bochicchio <a....@gmail.com>
AuthorDate: Mon Nov 2 10:43:40 2020 -0500

    Assert that requests contain bodies.
---
 .../digitalocean/_v2_domains_UNPROCESSABLE_ENTITY.json    |  1 +
 libcloud/test/dns/test_digitalocean.py                    | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libcloud/test/dns/fixtures/digitalocean/_v2_domains_UNPROCESSABLE_ENTITY.json b/libcloud/test/dns/fixtures/digitalocean/_v2_domains_UNPROCESSABLE_ENTITY.json
new file mode 100644
index 0000000..102aa9d
--- /dev/null
+++ b/libcloud/test/dns/fixtures/digitalocean/_v2_domains_UNPROCESSABLE_ENTITY.json
@@ -0,0 +1 @@
+{"id":"unprocessable_entity","message":"Request body malformed."}
diff --git a/libcloud/test/dns/test_digitalocean.py b/libcloud/test/dns/test_digitalocean.py
index 453e9c3..7e2c54e 100644
--- a/libcloud/test/dns/test_digitalocean.py
+++ b/libcloud/test/dns/test_digitalocean.py
@@ -110,7 +110,8 @@ class DigitalOceanDNSMockHttp(MockHttp):
         'EMPTY': httplib.OK,
         'NOT_FOUND': httplib.NOT_FOUND,
         'UNAUTHORIZED': httplib.UNAUTHORIZED,
-        'UPDATE': httplib.OK
+        'UPDATE': httplib.OK,
+        'UNPROCESSABLE': httplib.UNPROCESSABLE_ENTITY,
     }
 
     def _v2_domains(self, method, url, body, headers):
@@ -119,6 +120,10 @@ class DigitalOceanDNSMockHttp(MockHttp):
                 httplib.responses[self.response_map[self.type]])
 
     def _v2_domains_CREATE(self, method, url, body, headers):
+        if body is None:
+            body = self.fixtures.load('_v2_domains_UNPROCESSABLE_ENTITY.json')
+            return (self.response_map[self.type], body, {},
+                    httplib.responses[self.response_map['UNPROCESSABLE']])
         body = self.fixtures.load('_v2_domains_CREATE.json')
         return (self.response_map[self.type], body, {},
                 httplib.responses[self.response_map[self.type]])
@@ -144,6 +149,10 @@ class DigitalOceanDNSMockHttp(MockHttp):
 
     def _v2_domains_testdomain_records_CREATE(self, method, url,
                                               body, headers):
+        if body is None:
+            body = self.fixtures.load('_v2_domains_UNPROCESSABLE_ENTITY.json')
+            return (self.response_map[self.type], body, {},
+                    httplib.responses[self.response_map['UNPROCESSABLE']])
         body = self.fixtures.load('_v2_domains_testdomain_records_CREATE.json')
         return (self.response_map[self.type], body, {},
                 httplib.responses[self.response_map[self.type]])
@@ -163,6 +172,10 @@ class DigitalOceanDNSMockHttp(MockHttp):
 
     def _v2_domains_testdomain_records_1234564_UPDATE(
             self, method, url, body, headers):
+        if body is None:
+            body = self.fixtures.load('_v2_domains_UNPROCESSABLE_ENTITY.json')
+            return (self.response_map[self.type], body, {},
+                    httplib.responses[self.response_map['UNPROCESSABLE']])
         body = self.fixtures.load(
             '_v2_domains_testdomain_records_1234564_UPDATE.json')
         return (self.response_map[self.type], body, {},