@@ -34,6 +34,7 @@ class ZonomiTests(unittest.TestCase):
3434 def setUp (self ):
3535 ZonomiDNSDriver .connectionCls .conn_class = ZonomiMockHttp
3636 ZonomiMockHttp .type = None
37+ ZonomiMockHttp .history .clear ()
3738 self .driver = ZonomiDNSDriver (* DNS_PARAMS_ZONOMI )
3839 self .test_zone = Zone (
3940 id = "zone.com" ,
@@ -69,6 +70,11 @@ def test_list_zones_empty(self):
6970 def test_list_zones_success (self ):
7071 zones = self .driver .list_zones ()
7172
73+ sent = ZonomiMockHttp .history .pop ()
74+ self .assertEqual (sent .method , "GET" )
75+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
76+ self .assertIn ("QUERYZONES" , sent .query ["action" ])
77+
7278 self .assertEqual (len (zones ), 3 )
7379
7480 zone = zones [0 ]
@@ -105,6 +111,11 @@ def test_get_zone_GET_ZONE_SUCCESS(self):
105111 ZonomiMockHttp .type = "GET_ZONE_SUCCESS"
106112 zone = self .driver .get_zone (zone_id = "gamertest.com" )
107113
114+ sent = ZonomiMockHttp .history .pop ()
115+ self .assertEqual (sent .method , "GET" )
116+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
117+ self .assertIn ("QUERYZONES" , sent .query ["action" ])
118+
108119 self .assertEqual (zone .id , "gamertest.com" )
109120 self .assertEqual (zone .domain , "gamertest.com" )
110121 self .assertEqual (zone .type , "master" )
@@ -124,6 +135,12 @@ def test_delete_zone_delete_zone_success(self):
124135 ZonomiMockHttp .type = "DELETE_ZONE_SUCCESS"
125136 status = self .driver .delete_zone (zone = self .test_zone )
126137
138+ sent = ZonomiMockHttp .history .pop ()
139+ self .assertEqual (sent .method , "GET" )
140+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
141+ self .assertIn ("DELETEZONE" , sent .query ["action" ])
142+ self .assertIn ("zone.com" , sent .query ["name" ])
143+
127144 self .assertEqual (status , True )
128145
129146 def test_create_zone_already_exists (self ):
@@ -140,6 +157,11 @@ def test_create_zone_create_zone_success(self):
140157
141158 zone = self .driver .create_zone (domain = "myzone.com" )
142159
160+ sent = ZonomiMockHttp .history .pop ()
161+ self .assertEqual (sent .method , "GET" )
162+ self .assertEqual (sent .url , "/app/dns/addzone.jsp" )
163+ self .assertIn ("myzone.com" , sent .query ["name" ])
164+
143165 self .assertEqual (zone .id , "myzone.com" )
144166 self .assertEqual (zone .domain , "myzone.com" )
145167 self .assertEqual (zone .type , "master" )
@@ -153,6 +175,12 @@ def test_list_records_success(self):
153175 ZonomiMockHttp .type = "LIST_RECORDS_SUCCESS"
154176 records = self .driver .list_records (zone = self .test_zone )
155177
178+ sent = ZonomiMockHttp .history .pop ()
179+ self .assertEqual (sent .method , "GET" )
180+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
181+ self .assertIn ("QUERY" , sent .query ["action" ])
182+ self .assertIn ("**.zone.com" , sent .query ["name" ])
183+
156184 self .assertEqual (len (records ), 4 )
157185
158186 record = records [0 ]
@@ -213,6 +241,12 @@ def test_get_record_success(self):
213241 self .driver .get_zone = MagicMock (return_value = zone )
214242 record = self .driver .get_record (record_id = "oltjano" , zone_id = "zone.com" )
215243
244+ sent = ZonomiMockHttp .history .pop ()
245+ self .assertEqual (sent .method , "GET" )
246+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
247+ self .assertIn ("QUERY" , sent .query ["action" ])
248+ self .assertIn ("**.zone.com" , sent .query ["name" ])
249+
216250 self .assertEqual (record .id , "oltjano" )
217251 self .assertEqual (record .name , "oltjano" )
218252 self .assertEqual (record .type , "A" )
@@ -233,6 +267,13 @@ def test_delete_record_success(self):
233267 record = self .test_record
234268 status = self .driver .delete_record (record = record )
235269
270+ sent = ZonomiMockHttp .history .pop ()
271+ self .assertEqual (sent .method , "GET" )
272+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
273+ self .assertIn ("DELETE" , sent .query ["action" ])
274+ self .assertIn ("record.zone.com" , sent .query ["name" ])
275+ self .assertIn ("A" , sent .query ["type" ])
276+
236277 self .assertEqual (status , True )
237278
238279 def test_create_record_already_exists (self ):
@@ -254,6 +295,14 @@ def test_create_record_success(self):
254295 name = "createrecord" , zone = zone , type = "A" , data = "127.0.0.1" , extra = {}
255296 )
256297
298+ sent = ZonomiMockHttp .history .pop ()
299+ self .assertEqual (sent .method , "GET" )
300+ self .assertEqual (sent .url , "/app/dns/dyndns.jsp" )
301+ self .assertIn ("SET" , sent .query ["action" ])
302+ self .assertIn ("createrecord.zone.com" , sent .query ["name" ])
303+ self .assertIn ("A" , sent .query ["type" ])
304+ self .assertIn ("127.0.0.1" , sent .query ["value" ])
305+
257306 self .assertEqual (record .id , "createrecord" )
258307 self .assertEqual (record .name , "createrecord" )
259308 self .assertEqual (record .type , "A" )
@@ -293,6 +342,7 @@ def test_convert_to_master_couldnt_convert(self):
293342
294343class ZonomiMockHttp (MockHttp ):
295344 fixtures = DNSFileFixtures ("zonomi" )
345+ keep_history = True
296346
297347 def _app_dns_dyndns_jsp_EMPTY_ZONES_LIST (self , method , url , body , headers ):
298348 body = self .fixtures .load ("empty_zones_list.xml" )
0 commit comments