def test_delete_list(self): dictConfig(config.logging_config) logger = logging.getLogger() fruits = (["apple", "orange", "banana", "pears", "cherry", "mango"]) table = Table("testdb2", "test_table", "test_xcvzdfsadx2", config, logger) print(config.COG_HOME) store = table.store index = table.indexer.index_list[0] for fruit in fruits: print("storing :" + fruit) r = Record('fruits', fruit) print("CHECK IF LIST EXISTS - - - ->") record = index.get(r.key, store) if record is not None: print("prev record store pos: " + str(record.store_position)) r.set_value_link(record.store_position) position = store.save(r) print("stored new list value at store pos: " + str(position)) index.put(r.key, position, store) print("indexed") index.delete(r.key, store) returned_data = index.get(r.key, store) print("retrieved data: " + str(returned_data)) self.assertTrue(returned_data == None) index.close() store.close()
def test_put_get_list(self): dictConfig(config.logging_config) logger = logging.getLogger() fruits = (["apple", "orange", "banana", "pears", "cherry", "mango"]) table = Table("testdb2", "test_table", "test_xcvzdfsadx2", config, logger) store = table.store index = table.indexer.index_list[0] for fruit in fruits: print("storing :" + fruit) r = Record('fruits', fruit, value_type='l') print("CHECK IF LIST EXISTS - - - ->") read_record = index.get(r.key, store) # print("CHECK IF LIST EXISTS FOUND -> prev rec: "+str(record)+" get prev pos: "+str(record.store_position)) if read_record is not None: print("prev record store pos: " + str(read_record.store_position)) r.set_value_link(read_record.store_position) position = store.save(r) print("stored new list value at store pos: " + str(position)) index.put(r.key, position, store) print("indexed") returned_data = index.get(r.key, store) print("retrieved data: " + str(returned_data)) self.assertTrue( returned_data.is_equal_val( Record( 'fruits', ['mango', 'cherry', 'pears', 'banana', 'orange', 'apple' ]))) index.close() store.close()