def test_update_cell_dataset(self): store.dropAll() cds = CellDataSet("id") cells = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5'] for cell in cells: cds.add(CellID(cell), Data("")) store.insert(cds) cds2 = CellDataSet("id") cells2 = ['O0', 'O1', 'O2', 'O3', 'O4'] for cell in cells2: cds2.add(CellID(cell), Data("")) store.update_cell_dataset(cds2) stored_cds = store.query_by_cell_dataset_id("id") num_cds = 0 num_cells = 0 for cds in stored_cds: for cell in cds.get_cells(): assert cells2.__contains__(cell.value) num_cells = num_cells + 1 num_cds = num_cds + 1 self.assertEqual(num_cds, 1) self.assertEqual(num_cells, len(cells2)) store.dropAll()
def test_get_cells(self): cells = [CellID('N01'), CellID('N02'), CellID('N03')] data = Data('test') cell_data_set = { cells[0].value: (cells[0], data), cells[1].value: (cells[1], data), cells[2].value: (cells[2], data) } c_dataset = CellDataSet('id', cell_data_set=cell_data_set) self.assertEqual(c_dataset.get_cells(), cells)
def test_all_cell_datasets(self): store.dropAll() cds = CellDataSet("id") cells = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5'] for cell in cells: cds.add(CellID(cell), Data("")) store.insert(cds) stored_cds = store.all_cell_datasets() num_cds = 0 num_cells = 0 for cds in stored_cds: for cell in cds.get_cells(): assert cells.__contains__(cell.value) num_cells = num_cells + 1 num_cds = num_cds + 1 self.assertEqual(num_cds, 1) self.assertEqual(num_cells, len(cells)) store.dropAll()
def test_delete_cell_in_cell_datasets(self): store.dropAll() cds = CellDataSet("id") cells = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5'] for cell in cells: cds.add(CellID(cell), Data("")) store.insert(cds) deleted_cells = store.delete_cell_in_cell_datasets("id", CellID('P0')) self.assertEqual(deleted_cells, 1) stored_cds = store.query_by_cell_in_cell_datasets("id", CellID('P0')) num_cds = 0 for cds in stored_cds: assert cds.get_cells().__len__() == 0 num_cds = num_cds + 1 self.assertEqual(num_cds, 1) store.dropAll()