

def test__reschedule_hosting_devices_to_other_cfg_agent(self):
    random_patch = mock.patch('random.choice')
    random_mock = random_patch.start()

    def side_effect(seq):
        return seq[0]
    random_mock.side_effect = side_effect
    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_1, self.hosting_device(template_id=hdt['id']) as hosting_device_2:
            cfg_agent_id1 = self._agent_dict[L3_CFG_HOST_A]['id']
            self._test_assign_hosting_device_to_cfg_agent(hosting_device_1, cfg_agent_id1)
            self._test_assign_hosting_device_to_cfg_agent(hosting_device_2, cfg_agent_id1)
            hds_after = self._list('hosting_devices')['hosting_devices']
            for hd_after in hds_after:
                self.assertEqual(cfg_agent_id1, 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, False, True, False]
                self.plugin._reschedule_hosting_devices(e_context, cfg_agent_id1)
                cfg_agent_id2 = self._agent_dict[L3_CFG_HOST_B]['id']
                hds_final = self._list('hosting_devices')['hosting_devices']
                for hd_final in hds_final:
                    self.assertEqual(cfg_agent_id2, hd_final['cfg_agent_id'])
    assign_notify_mock = notify_mock.hosting_devices_assigned_to_cfg_agent
    hd_ids = [hd['id'] for hd in hds_final]
    assign_notify_mock.assert_called_once_with(mock.ANY, is_older_mock, self._agent_dict[L3_CFG_HOST_B]['host'])
    random_patch.stop()

dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_hosting_device_cfg_agent_scheduler.py HostingDeviceConfigAgentSchedulerTestCase.test__reschedule_hosting_devices_to_other_cfg_agent/VarMisuse@314/610 `hd_ids`->`is_older_mock`