def test_pos_operate_with_list_size(self): """ Invoke operate() with list_size operation """ key = ('test', 'demo', 'list_key') list = [list_operations.list_size("int_bin")] key, _, bins = self.as_connection.operate(key, list) assert bins == {'int_bin': 4}
def test_pos_operate_with_list_size(self): """ Invoke operate() with list_size operation """ key = ('test', 'demo', 'list_key') list = [ list_operations.list_size("int_bin") ] key, _, bins = self.as_connection.operate(key, list) assert bins == {'int_bin': 4}
sys.exit(2) key = (options.namespace, options.set, "list-sort") try: client.remove(key) except ex.RecordError as e: pass try: print("\nsize(bin[, context])\n") # create a record with an unordered list client.put(key, {"l": [1, 2, [3, 4]]}) key, metadata, bins = client.get(key) print("{}".format(bins["l"])) # [1, 2, [3, 4]] key, metadata, bins = client.operate(key, [listops.list_size("l")]) print("\nsize('l'): {}".format(bins["l"])) # The size of the list is 3 # get the size of the inner list (at index 2) ctx = [cdt_ctx.cdt_ctx_list_index(2)] key, metadata, bins = client.operate(key, [listops.list_size("l", ctx=ctx)]) print("\nsize('l', BY_LIST_INDEX(4)): {}".format(bins["l"])) # The size of the sub-list is 2 except ex.ClientError as e: print("Error: {0} [{1}]".format(e.msg, e.code)) client.close()