def _test_slots(self, expected_result=True, expected_bind=UNBOUND,
                    expected_allocation=VM_SLOT_CAPACITY,
                    num_requested=VM_SLOT_CAPACITY,
                    slot_capacity=VM_SLOT_CAPACITY, initial_bind=UNBOUND,
                    bind=False, auto_delete=True, is_admin=False,
                    pool_maintenance_expected=True, test_release=False,
                    expected_release_result=True, expected_final_allocation=0,
                    expected_release_bind=UNBOUND,
                    num_to_release=VM_SLOT_CAPACITY,
                    release_pool_maintenance_expected=True):
        with self.hosting_device_template(
                slot_capacity=slot_capacity) as hdt:
            with self.port(subnet=self._mgmt_subnet) as mgmt_port:
                resource = self._get_fake_resource()
                tenant_bound = self._set_ownership(
                    initial_bind, resource['tenant_id'])
                with self.hosting_device(
                        template_id=hdt['hosting_device_template']['id'],
                        management_port_id=mgmt_port['port']['id'],
                        tenant_bound=tenant_bound,
                        auto_delete=auto_delete) as hd:
                    context = self._get_test_context(
                        tenant_id=hdt['hosting_device_template']['tenant_id'],
                        is_admin=is_admin)
                    hd_db = self._devmgr._get_hosting_device(
                        context, hd['hosting_device']['id'])
                    with mock.patch.object(
                            hdm_db.HostingDeviceManagerMixin,
                            '_dispatch_pool_maintenance_job') as pm_mock:
                        result = self._devmgr.acquire_hosting_device_slots(
                            context, hd_db, resource, 'router', L3_ROUTER_NAT,
                            num_requested, bind)
                        allocation = self._devmgr.get_slot_allocation(
                            context, resource_id=resource['id'])
                        self.assertEqual(expected_result, result)
                        self.assertEqual(expected_allocation, allocation)
                        expected_bind = self._set_ownership(
                            expected_bind, resource['tenant_id'])
                        self.assertEqual(expected_bind, hd_db.tenant_bound)
                        if pool_maintenance_expected:
                            pm_mock.assert_called_once_with(mock.ANY)
                            num_calls = 1
                        else:
                            pm_mock.assert_not_called()
                            num_calls = 0
                        if test_release:
                            result = self._devmgr.release_hosting_device_slots(
                                context, hd_db, resource, num_to_release)
                            if not test_release:
                                return
                            allocation = self._devmgr.get_slot_allocation(
                                context, resource_id=resource['id'])
                            self.assertEqual(expected_release_result, result)
                            self.assertEqual(expected_final_allocation,
                                             allocation)
                            expected_release_bind = self._set_ownership(
                                expected_release_bind, resource['tenant_id'])
                            self.assertEqual(expected_release_bind,
                                             hd_db.tenant_bound)
                            if release_pool_maintenance_expected:
                                num_calls += 1
                            self.assertEqual(num_calls, pm_mock.call_count)
                        else:
                            # ensure we clean up everything
                            num_to_release = 0
                        to_clean_up = num_requested - num_to_release
                        if to_clean_up is 0:
                            to_clean_up = num_requested
                        if to_clean_up:
                            self._devmgr.release_hosting_device_slots(
                                context, hd_db, resource, to_clean_up)

    # slot allocation tests
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_db_device_manager.py/TestDeviceManagerDBPlugin._test_slots/operator `<` -> `is`