@@ -65,6 +65,7 @@ class RackspaceUSTests(unittest.TestCase):
6565 def setUp (self ):
6666 self .klass .connectionCls .conn_class = RackspaceMockHttp
6767 RackspaceMockHttp .type = None
68+ RackspaceMockHttp .history .clear ()
6869
6970 driver_kwargs = {"region" : self .region }
7071 self .driver = self .klass (* DNS_PARAMS_RACKSPACE , ** driver_kwargs )
@@ -108,6 +109,10 @@ def test_list_record_types(self):
108109 def test_list_zones_success (self ):
109110 zones = self .driver .list_zones ()
110111
112+ sent = RackspaceMockHttp .history .pop ()
113+ self .assertEqual (sent .method , "GET" )
114+ self .assertEqual (sent .url , "/v1.0/11111/domains" )
115+
111116 self .assertEqual (len (zones ), 6 )
112117 self .assertEqual (zones [0 ].domain , "foo4.bar.com" )
113118 self .assertEqual (zones [0 ].extra ["comment" ], "wazaaa" )
@@ -131,6 +136,10 @@ def test_list_records_success(self):
131136 zone = self .driver .list_zones ()[0 ]
132137 records = self .driver .list_records (zone = zone )
133138
139+ sent = RackspaceMockHttp .history .pop ()
140+ self .assertEqual (sent .method , "GET" )
141+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063" )
142+
134143 self .assertEqual (len (records ), 3 )
135144 self .assertEqual (records [0 ].name , "test3" )
136145 self .assertEqual (records [0 ].type , RecordType .A )
@@ -160,6 +169,10 @@ def test_get_zone_success(self):
160169 RackspaceMockHttp .type = "GET_ZONE"
161170 zone = self .driver .get_zone (zone_id = "2946063" )
162171
172+ sent = RackspaceMockHttp .history .pop ()
173+ self .assertEqual (sent .method , "GET" )
174+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063" )
175+
163176 self .assertEqual (zone .id , "2946063" )
164177 self .assertEqual (zone .domain , "foo4.bar.com" )
165178 self .assertEqual (zone .type , "master" )
@@ -176,7 +189,12 @@ def test_get_zone_does_not_exist(self):
176189 self .fail ("Exception was not thrown" )
177190
178191 def test_get_record_success (self ):
179- record = self .driver .get_record (zone_id = "12345678" , record_id = "23456789" )
192+ record = self .driver .get_record (zone_id = "12345678" , record_id = "A-7423034" )
193+
194+ sent = RackspaceMockHttp .history .pop ()
195+ self .assertEqual (sent .method , "GET" )
196+ self .assertEqual (sent .url , "/v1.0/11111/domains/12345678/records/A-7423034" )
197+
180198 self .assertEqual (record .id , "A-7423034" )
181199 self .assertEqual (record .name , "test3" )
182200 self .assertEqual (record .type , RecordType .A )
@@ -211,6 +229,17 @@ def test_create_zone_success(self):
211229 ttl = None ,
212230 extra = {"email" : "test@test.com" },
213231 )
232+
233+ # [0] POST /v2.0/tokens
234+ # [1] POST /v1.0/{account}/domains
235+ # [2] GET /v1.0/{account}/status/...
236+ sent = RackspaceMockHttp .history .pop (1 )
237+ self .assertEqual (sent .method , "POST" )
238+ self .assertEqual (sent .url , "/v1.0/11111/domains" )
239+ domain = sent .json ["domains" ][0 ]
240+ self .assertEqual (domain ["name" ], "bar.foo1.com" )
241+ self .assertEqual (domain ["emailAddress" ], "test@test.com" )
242+
214243 self .assertEqual (zone .id , "2946173" )
215244 self .assertEqual (zone .domain , "bar.foo1.com" )
216245 self .assertEqual (zone .type , "master" )
@@ -238,8 +267,17 @@ def test_create_zone_validaton_error(self):
238267
239268 def test_update_zone_success (self ):
240269 zone = self .driver .list_zones ()[0 ]
270+ sent = RackspaceMockHttp .history .clear ()
271+
241272 updated_zone = self .driver .update_zone (zone = zone , extra = {"comment" : "bar foo" })
242273
274+ # [0] PUT "/v1.0/{account}/domains/{zone.id}"
275+ # [1] GET "/v1.0/{account}/status/...
276+ sent = RackspaceMockHttp .history .pop (0 )
277+ self .assertEqual (sent .method , "PUT" )
278+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063" )
279+ self .assertIn ("comment" , sent .json )
280+
243281 self .assertEqual (zone .extra ["comment" ], "wazaaa" )
244282
245283 self .assertEqual (updated_zone .id , zone .id )
@@ -260,12 +298,23 @@ def test_update_zone_domain_cannot_be_changed(self):
260298
261299 def test_create_record_success (self ):
262300 zone = self .driver .list_zones ()[0 ]
301+ sent = RackspaceMockHttp .history .clear ()
263302
264303 RackspaceMockHttp .type = "CREATE_RECORD"
265304 record = self .driver .create_record (
266305 name = "www" , zone = zone , type = RecordType .A , data = "127.1.1.1"
267306 )
268307
308+ # [0] POST /v1.0/{account}/domains/{zone.id}/records
309+ # [1] GET /v1.0/{account}/status/...
310+ sent = RackspaceMockHttp .history .pop (0 )
311+ self .assertEqual (sent .method , "POST" )
312+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063/records" )
313+ records = sent .json ["records" ]
314+ self .assertEqual (records [0 ]["name" ], "www.foo4.bar.com" )
315+ self .assertEqual (records [0 ]["type" ], "A" )
316+ self .assertEqual (records [0 ]["data" ], "127.1.1.1" )
317+
269318 self .assertEqual (record .id , "A-7423317" )
270319 self .assertEqual (record .name , "www" )
271320 self .assertEqual (record .zone , zone )
@@ -276,8 +325,18 @@ def test_create_record_success(self):
276325 def test_update_record_success (self ):
277326 zone = self .driver .list_zones ()[0 ]
278327 record = self .driver .list_records (zone = zone )[0 ]
328+ sent = RackspaceMockHttp .history .clear ()
329+
279330 updated_record = self .driver .update_record (record = record , data = "127.3.3.3" )
280331
332+ # [0] POST /v1.0/{account}/domains/{zone.id}/records/{record.id}
333+ # [1] GET /v1.0/{account}/status/...
334+ sent = RackspaceMockHttp .history .pop (0 )
335+ self .assertEqual (sent .method , "PUT" )
336+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063/records/A-7423034" )
337+ self .assertEqual (sent .json ["name" ], "test3.foo4.bar.com" )
338+ self .assertEqual (sent .json ["data" ], "127.3.3.3" )
339+
281340 self .assertEqual (record .name , "test3" )
282341 self .assertEqual (record .data , "127.7.7.7" )
283342
@@ -289,7 +348,16 @@ def test_update_record_success(self):
289348
290349 def test_delete_zone_success (self ):
291350 zone = self .driver .list_zones ()[0 ]
351+ sent = RackspaceMockHttp .history .clear ()
352+
292353 status = self .driver .delete_zone (zone = zone )
354+
355+ # [0] DELETE /v1.0/{account}/domains/{zone.id}
356+ # [1] GET /v1.0/{account}/status/...
357+ sent = RackspaceMockHttp .history .pop (0 )
358+ self .assertEqual (sent .method , "DELETE" )
359+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063" )
360+
293361 self .assertTrue (status )
294362
295363 def test_delete_zone_does_not_exist (self ):
@@ -307,7 +375,16 @@ def test_delete_zone_does_not_exist(self):
307375 def test_delete_record_success (self ):
308376 zone = self .driver .list_zones ()[0 ]
309377 record = self .driver .list_records (zone = zone )[0 ]
378+ sent = RackspaceMockHttp .history .clear ()
379+
310380 status = self .driver .delete_record (record = record )
381+
382+ # [0] DELETE /v1.0/{account}/domains/{zone.id}/records/{record.id}
383+ # [1] GET /v1.0/{account}/status/...
384+ sent = RackspaceMockHttp .history .pop (0 )
385+ self .assertEqual (sent .method , "DELETE" )
386+ self .assertEqual (sent .url , "/v1.0/11111/domains/2946063/records/A-7423034" )
387+
311388 self .assertTrue (status )
312389
313390 def test_delete_record_does_not_exist (self ):
@@ -416,6 +493,7 @@ class RackspaceUKTests(RackspaceUSTests):
416493
417494class RackspaceMockHttp (MockHttp ):
418495 fixtures = DNSFileFixtures ("rackspace" )
496+ keep_history = True
419497 base_headers = {"content-type" : "application/json" }
420498
421499 def _v2_0_tokens (self , method , url , body , headers ):
@@ -482,7 +560,7 @@ def _v1_0_11111_domains_12345678(self, method, url, body, headers):
482560 body = self .fixtures .load ("get_zone_success.json" )
483561 return (httplib .OK , body , self .base_headers , httplib .responses [httplib .OK ])
484562
485- def _v1_0_11111_domains_12345678_records_23456789 (self , method , url , body , headers ):
563+ def _v1_0_11111_domains_12345678_records_A_7423034 (self , method , url , body , headers ):
486564 body = self .fixtures .load ("get_record_success.json" )
487565 return (httplib .OK , body , self .base_headers , httplib .responses [httplib .OK ])
488566
0 commit comments