'Tests that the get_config() method is properly called in
attach_interface() and detach_interface().
method_name: either "attach_interface" or "detach_interface"
depending on the method to test.'

def _test_attach_detach_interface_get_config(self, method_name):

    self.stubs.Set(host.Host, 'get_domain', (lambda a, b: FakeVirtDomain()))
    instance = objects.Instance(**self.test_instance)
    network_info = _fake_network_info(self, 1)
    drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
    fake_image_meta = objects.ImageMeta.from_dict({'id': instance['image_ref']})
    if (method_name == 'attach_interface'):
        self.mox.StubOutWithMock(drvr.firewall_driver, 'setup_basic_filtering')
        drvr.firewall_driver.setup_basic_filtering(instance, network_info)
        self.mox.StubOutWithMock(drvr, '_build_device_metadata')
        drvr._build_device_metadata(self.context, instance).AndReturn(objects.InstanceDeviceMetadata())
        self.mox.StubOutWithMock(objects.Instance, 'save')
        objects.Instance.save()
    expected = drvr.vif_driver.get_config(instance, network_info[0], fake_image_meta, instance.get_flavor(), CONF.libvirt.virt_type, drvr._host)
    self.mox.StubOutWithMock(drvr.vif_driver, 'get_config')
    drvr.vif_driver.get_config(instance, network_info[0], mox.IsA(objects.ImageMeta), mox.IsA(objects.Flavor), CONF.libvirt.virt_type, drvr._host).AndReturn(expected)
    self.mox.ReplayAll()
    if (method_name == 'attach_interface'):
        drvr.attach_interface(self.context, instance, fake_image_meta, network_info[0])
    elif (method_name == 'detach_interface'):
        drvr.detach_interface(self.context, instance, network_info[0])
    else:
        raise ValueError(('Unhandled    method    %s' % method_name))
