

def test_get_cfg_agents_for_hosting_devices_reschedules_from_dead(self):
    self._setup_cfg_agents(True, True)
    with self.hosting_device_template(host_category=self.host_category) as hosting_device_template:
        hdt = hosting_device_template['hosting_device_template']
        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._test_assign_hosting_device_to_cfg_agent(hosting_device, cfg_agent_id)
            with mock.patch('networking_cisco.plugins.cisco.db.scheduler.cfg_agentschedulers_db.timeutils.is_older_than') as is_older_mock:
                is_older_mock.side_effect = [True, True, False]
                agents = self.plugin.get_cfg_agents_for_hosting_devices(self.adminContext, [hd['id']], schedule=True)
                cfg_agent_id_after = self._agent_dict[L3_CFG_HOST_B]['id']
                self.assertEqual(1, len(agents))
                self.assertEqual(cfg_agent_id_after, agents[0]['id'])
                hosting_device_after = self._show('hosting_devices', hd['id'])
                hd_after = hosting_device_after['hosting_device']
                self.assertEqual(cfg_agent_id_after, hd_after['cfg_agent_id'])

dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_hosting_device_cfg_agent_scheduler.py HostingDeviceConfigAgentSchedulerTestCase.test_get_cfg_agents_for_hosting_devices_reschedules_from_dead/original