def _test_delete(self, to_delete=None, auto_delete=None, no_delete=None,
                     force_delete=True, expected_num_remaining=0):
        auto_delete = auto_delete or [True, False, False, True, True]
        no_delete = no_delete or [True, True, True, True, True]
        with self.hosting_device_template() as hdt1,\
                self.hosting_device_template() as hdt2:
            hdt0_id = hdt1['hosting_device_template']['id']
            hdt1_id = hdt2['hosting_device_template']['id']
            with self.port(subnet=self._mgmt_subnet,
                           no_delete=no_delete[0]) as mgmt_port0,\
                    self.port(subnet=self._mgmt_subnet,
                              no_delete=no_delete[1]) as mgmt_port1,\
                    self.port(subnet=self._mgmt_subnet,
                              no_delete=no_delete[2]) as mgmt_port2,\
                    self.port(subnet=self._mgmt_subnet,
                              no_delete=no_delete[3]) as mgmt_port3,\
                    self.port(subnet=self._mgmt_subnet,
                              no_delete=no_delete[4]) as mgmt_port4:
                mp0_id = mgmt_port0['port']['id']
                mp1_id = mgmt_port1['port']['id']
                mp2_id = mgmt_port2['port']['id']
                mp3_id = mgmt_port3['port']['id']
                mp4_id = mgmt_port4['port']['id']
                with self.hosting_device(
                        device_id='0_hdt0_id', template_id=hdt0_id,
                        management_port_id=mp0_id, auto_delete=auto_delete[0],
                        no_delete=no_delete[0]),\
                    self.hosting_device(
                        device_id='1_hdt1_id', template_id=hdt1_id,
                        management_port_id=mp1_id, auto_delete=auto_delete[1],
                        no_delete=no_delete[1]),\
                    self.hosting_device(
                        device_id='2_hdt0_id', template_id=hdt0_id,
                        management_port_id=mp2_id, auto_delete=auto_delete[2],
                        no_delete=no_delete[2]),\
                    self.hosting_device(
                        device_id='3_hdt0_id', template_id=hdt0_id,
                        management_port_id=mp3_id,
                        auto_delete=auto_delete[3],
                        no_delete=no_delete[3]),\
                    self.hosting_device(
                        device_id='4_hdt1_id', template_id=hdt1_id,
                        management_port_id=mp4_id, auto_delete=auto_delete[4],
                        no_delete=no_delete[4]):
                        context = self._get_test_context(is_admin=True)
                        if to_delete is None:
                            self._devmgr.delete_all_hosting_devices(
                                context, force_delete)
                        elif to_delete == 0:
                            template = (
                                self._devmgr._get_hosting_device_template(
                                    context, hdt0_id))
                            (self._devmgr.
                                delete_all_hosting_devices_by_template(
                                    context, template, force_delete))
                        else:
                            template = (
                                self._devmgr._get_hosting_device_template(
                                    context, hdt1_id))
                            (self._devmgr.
                                delete_all_hosting_devices_by_template(
                                    context, template, force_delete))
                        result_hds = self._list(
                            'hosting_devices')['hosting_devices']
                        self.assertEqual(expected_num_remaining,
                                         len(result_hds))

    # hosting device deletion tests
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_db_device_manager.py/TestDeviceManagerDBPlugin._test_delete/original