def test_config_get_new_pool_id(mock_get_config): def get_max_cos_id(alloc_type): if 'mba' in alloc_type: return 9 else: return 31 with mock.patch('common.PQOS_API.get_max_cos_id', new=get_max_cos_id): config_store = ConfigStore() mock_get_config.return_value = CONFIG assert 9 == config_store.get_new_pool_id({"mba":10}) assert 9 == config_store.get_new_pool_id({"mba":20, "cbm":"0xf0"}) assert 31 == config_store.get_new_pool_id({"cbm":"0xff"}) assert 31 == config_store.get_new_pool_id({"l2cbm":"0xff"}) assert 31 == config_store.get_new_pool_id({"l2cbm":"0xff"}) assert 31 == config_store.get_new_pool_id({"l2cbm":"0xff", "cbm":"0xf0"}) mock_get_config.return_value = CONFIG_POOLS assert 8 == config_store.get_new_pool_id({"mba":10}) assert 8 == config_store.get_new_pool_id({"mba":20, "cbm":"0xf0"}) assert 30 == config_store.get_new_pool_id({"cbm":"0xff"}) assert 30 == config_store.get_new_pool_id({"l2cbm":"0xff"}) assert 30 == config_store.get_new_pool_id({"l2cbm":"0xff", "cbm":"0xf0"})