

def test_hosting_device_unassign_from_cfg_agent_notification(self):
    cfg_notifier = self.plugin.agent_notifiers[c_const.AGENT_TYPE_CFG]
    with mock.patch.object(cfg_notifier.client, 'prepare', return_value=cfg_notifier.client) as mock_prepare, mock.patch.object(cfg_notifier.client, 'cast') as mock_cast, self.hosting_device_template(host_category=self.host_category) as hosting_device_template:
        hdt = hosting_device_template['hosting_device_template']
        self._setup_cfg_agents()
        with self.hosting_device(template_id=hdt['id']) as hosting_device:
            hd = hosting_device['hosting_device']
            cfg_agent_id = self._agent_dict[L3_CFG_HOST_A]['id']
            self._assign_hosting_device_to_cfg_agent(cfg_agent_id, hd['id'])
            self._unassign_hosting_device_from_cfg_agent(cfg_agent_id, hd['id'])
            mock_prepare.assert_called_with(server=L3_CFG_HOST_A)
            mock_cast.assert_called_with(mock.ANY, 'hosting_devices_unassigned_from_cfg_agent', payload={
                'hosting_device_ids': [hd['id']],
            })
            notifications = fake_notifier.NOTIFICATIONS
            expected_event_type = 'agent.hosting_device.remove'
            self._assert_notify(notifications, expected_event_type)

dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_hosting_device_cfg_agent_scheduler.py HostingDeviceConfigAgentNotifierTestCase.test_hosting_device_unassign_from_cfg_agent_notification/original