@@ -232,9 +232,10 @@ def test_dns_setup_failure_from_create_cf_zone(self, mock_create_cf_account, moc
232232 # mock_create_cf_zone.assert_called_once_with(zone_name, account_id) not sure why this fails: 0 calls
233233 self .assertIn ("DNS setup failed to create zone" , str (context .exception ))
234234
235+ @patch ("registrar.models.dns.dns_record.DnsRecord.get_by_x_record_id" )
235236 @patch ("registrar.models.dns.dns_record.DnsRecord.create_from_vendor_data" )
236237 @patch ("registrar.services.dns_host_service.CloudflareService.create_dns_record" )
237- def test_create_cf_record_success (self , mock_create_dns_record , _ ):
238+ def test_create_cf_record_success (self , mock_create_dns_record , _ , mock_get_by_x_record_id ):
238239 zone_id = "1234"
239240 record_data = {
240241 "type" : "A" ,
@@ -245,11 +246,14 @@ def test_create_cf_record_success(self, mock_create_dns_record, _):
245246 "created_on" : "2024-01-02T03:04:05Z" ,
246247 }
247248
249+ mock_dns_record = Mock ()
250+ mock_dns_record .name = "test.gov"
248251 mock_create_dns_record .return_value = {"result" : {"id" : zone_id , ** record_data }}
252+ mock_get_by_x_record_id .return_value = mock_dns_record
249253
250- response = self .service .create_and_save_record (zone_id , record_data )
251- self .assertEqual (response [ "result" ][ "id" ], zone_id )
252- self . assertEqual ( response [ "result" ][ "name" ], "test.gov" )
254+ response = self .service .create_dns_record (zone_id , record_data )
255+ self .assertEqual (response . name , "test.gov" )
256+ mock_get_by_x_record_id . assert_called_once_with ( zone_id )
253257
254258 @patch ("registrar.services.dns_host_service.CloudflareService.create_dns_record" )
255259 def test_create_cf_record_failure (self , mock_create_dns_record ):
@@ -260,7 +264,7 @@ def test_create_cf_record_failure(self, mock_create_dns_record):
260264 mock_create_dns_record .side_effect = APIError ("Bad request: missing name" )
261265
262266 with self .assertRaises (APIError ) as context :
263- self .service .create_and_save_record (zone_id , record_data )
267+ self .service .create_dns_record (zone_id , record_data )
264268 self .assertIn ("Bad request: missing name" , str (context .exception ))
265269
266270 def test_update_account_dns_settings_success (self ):
0 commit comments