def setUp(self): super(ImagePropertiesFilter, self).setUp() self.cell1 = models.Cell() self.cell2 = models.Cell() self.cell3 = models.Cell() self.cells = [self.cell1, self.cell2, self.cell3] for cell in self.cells: cell.capabilities = {} self.filter_props = {'context': self.context, 'request_spec': {}}
def setUp(self): super(TestCellsGetCapacity, self).setUp() self.capacities = {"ram_free": 1234} self.state_manager = self._get_state_manager() cell = models.Cell(name="cell_name") other_cell = models.Cell(name="other_cell_name") cell.capacities = self.capacities other_cell.capacities = self.capacities self.stubs.Set(self.state_manager, 'child_cells', {"cell_name": cell, "other_cell_name": other_cell})
def _stub_cells(self, num_cells=5): self.cell_list = [] self.cells_next_id = 1 def _fake_cell_get_all(context): return self.cell_list 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) for x in xrange(num_cells): cell = models.Cell() our_id = self.cells_next_id self.cells_next_id += 1 cell.update({ 'id': our_id, 'name': 'cell%s' % our_id, 'transport_url': 'rabbit://username%s@/' % our_id, 'is_parent': our_id % 2 == 0 }) self.cell_list.append(cell) self.stubs.Set(db, 'cell_get_all', _fake_cell_get_all) self.stubs.Set(cells_rpcapi.CellsAPI, 'cell_get', _fake_cell_get)