'Helper function for testing domain updates.'

def test_update_record_only(self):

    fake_dns_instance = FakeDnsInstance()
    t = template_format.parse(domain_only_template)
    instance = self._setup_test_cloud_dns_instance('dnsinstance_update', t)
    instance.resource_id = 4
    update_records = [{'type': 'A', 'name': 'ftp.example.com', 'data': '192.0.2.8', 'ttl': 3600}]
    mock_client = self.m.CreateMockAnything()
    self.m.StubOutWithMock(instance, 'cloud_dns')
    instance.cloud_dns().AndReturn(mock_client)
    self.m.StubOutWithMock(mock_client, 'get')
    mock_domain = self.m.CreateMockAnything()
    mock_client.get(fake_dns_instance.resource_id).AndReturn(mock_domain)
    self.m.StubOutWithMock(mock_domain, 'update')
    fake_records = list()
    mock_domain.list_records().AndReturn(fake_records)
    mock_domain.add_records([{'comment': None, 'priority': None, 'type': 'A', 'name': 'ftp.example.com', 'data': '192.0.2.8', 'ttl': 3600}])
    self.m.ReplayAll()
    uprops = dict(instance.properties)
    uprops['records'] = update_records
    ut = rsrc_defn.ResourceDefinition(instance.name, instance.type(), uprops)
    instance.state_set(instance.CREATE, instance.COMPLETE)
    scheduler.TaskRunner(instance.update, ut)()
    self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
    self.m.VerifyAll()
