

def test__reschedule_hosting_devices_no_other_cfg_agent(self):
    self._setup_cfg_agents(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)
            hd_after = self._show('hosting_devices', hd['id'])['hosting_device']
            self.assertEqual(cfg_agent_id, hd_after['cfg_agent_id'])
            notify_mock = mock.MagicMock()
            self.plugin.agent_notifiers[c_const.AGENT_TYPE_CFG] = notify_mock
            e_context = n_context.get_admin_context()
            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]
                self.plugin._reschedule_hosting_devices(e_context, cfg_agent_id)
                hd_final = self._show('hosting_devices', hd['id'])['hosting_device']
                self.assertIsNone(hd_final['cfg_agent_id'])
                self.assertEqual(0, notify_mock.call_count)

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