def test_show_capacities_for_invalid_cell(self): if (self.cell_extension == 'compute_extension:cells'): self.ext_mgr.is_loaded('os-cell-capacities').AndReturn(True) self.mox.StubOutWithMock(self.controller.cells_rpcapi, 'get_capacities') self.controller.cells_rpcapi. \ get_capacities(self.context, cell_name="invalid_cell").AndRaise( exception.CellNotFound(cell_name="invalid_cell")) self.mox.ReplayAll() req = self._get_request("cells/invalid_cell/capacities") req.environ["patron.context"] = self.context self.assertRaises(exc.HTTPNotFound, self.controller.capacities, req, "invalid_cell")
def _fake_cell_get(inst, context, cell_name): for cell in self.cell_list: if cell['name'] == cell_name: return cell raise exception.CellNotFound(cell_name=cell_name)
def cell_get(self, ctxt, cell_name): for cells_dict in (self.parent_cells, self.child_cells): if cell_name in cells_dict: return cells_dict[cell_name] raise exception.CellNotFound(cell_name=cell_name)
def fake_cell_get(_self, context, cell_name): for cell in self.fake_cells: if cell_name == cell['name']: return cell else: raise exception.CellNotFound(cell_name=cell_name)
def get_capacities(self, cell_name=None): if not cell_name or cell_name == self.my_cell_state.name: return self.get_our_capacities() if cell_name in self.child_cells: return self.child_cells[cell_name].capacities raise exception.CellNotFound(cell_name=cell_name)