diff --git a/redis/commands/bf/__init__.py b/redis/commands/bf/__init__.py index f34e11d9bb..d62d8a0d83 100644 --- a/redis/commands/bf/__init__.py +++ b/redis/commands/bf/__init__.py @@ -18,70 +18,70 @@ class AbstractBloom(object): """ @staticmethod - def appendItems(params, items): + def append_items(params, items): """Append ITEMS to params.""" params.extend(["ITEMS"]) params += items @staticmethod - def appendError(params, error): + def append_error(params, error): """Append ERROR to params.""" if error is not None: params.extend(["ERROR", error]) @staticmethod - def appendCapacity(params, capacity): + def append_capacity(params, capacity): """Append CAPACITY to params.""" if capacity is not None: params.extend(["CAPACITY", capacity]) @staticmethod - def appendExpansion(params, expansion): + def append_expansion(params, expansion): """Append EXPANSION to params.""" if expansion is not None: params.extend(["EXPANSION", expansion]) @staticmethod - def appendNoScale(params, noScale): + def append_no_scale(params, noScale): """Append NONSCALING tag to params.""" if noScale is not None: params.extend(["NONSCALING"]) @staticmethod - def appendWeights(params, weights): + def append_weights(params, weights): """Append WEIGHTS to params.""" if len(weights) > 0: params.append("WEIGHTS") params += weights @staticmethod - def appendNoCreate(params, noCreate): + def append_no_create(params, noCreate): """Append NOCREATE tag to params.""" if noCreate is not None: params.extend(["NOCREATE"]) @staticmethod - def appendItemsAndIncrements(params, items, increments): + def append_items_and_increments(params, items, increments): """Append pairs of items and increments to params.""" for i in range(len(items)): params.append(items[i]) params.append(increments[i]) @staticmethod - def appendValuesAndWeights(params, items, weights): + def append_values_and_weights(params, items, weights): """Append pairs of items and weights to params.""" for i in range(len(items)): params.append(items[i]) params.append(weights[i]) @staticmethod - def appendMaxIterations(params, max_iterations): + def append_max_iterations(params, max_iterations): """Append MAXITERATIONS to params.""" if max_iterations is not None: params.extend(["MAXITERATIONS", max_iterations]) @staticmethod - def appendBucketSize(params, bucket_size): + def append_bucket_size(params, bucket_size): """Append BUCKETSIZE to params.""" if bucket_size is not None: params.extend(["BUCKETSIZE", bucket_size]) diff --git a/redis/commands/bf/commands.py b/redis/commands/bf/commands.py index 7fc507d2d9..e911efc621 100644 --- a/redis/commands/bf/commands.py +++ b/redis/commands/bf/commands.py @@ -62,8 +62,8 @@ def create(self, key, errorRate, capacity, expansion=None, noScale=None): For more information see `BF.RESERVE `_. """ # noqa params = [key, errorRate, capacity] - self.appendExpansion(params, expansion) - self.appendNoScale(params, noScale) + self.append_expansion(params, expansion) + self.append_no_scale(params, noScale) return self.execute_command(BF_RESERVE, *params) def add(self, key, item): @@ -102,12 +102,12 @@ def insert( For more information see `BF.INSERT `_. """ # noqa params = [key] - self.appendCapacity(params, capacity) - self.appendError(params, error) - self.appendExpansion(params, expansion) - self.appendNoCreate(params, noCreate) - self.appendNoScale(params, noScale) - self.appendItems(params, items) + self.append_capacity(params, capacity) + self.append_error(params, error) + self.append_expansion(params, expansion) + self.append_no_create(params, noCreate) + self.append_no_scale(params, noScale) + self.append_items(params, items) return self.execute_command(BF_INSERT, *params) @@ -177,9 +177,9 @@ def create( For more information see `CF.RESERVE `_. """ # noqa params = [key, capacity] - self.appendExpansion(params, expansion) - self.appendBucketSize(params, bucket_size) - self.appendMaxIterations(params, max_iterations) + self.append_expansion(params, expansion) + self.append_bucket_size(params, bucket_size) + self.append_max_iterations(params, max_iterations) return self.execute_command(CF_RESERVE, *params) def add(self, key, item): @@ -207,9 +207,9 @@ def insert(self, key, items, capacity=None, nocreate=None): For more information see `CF.INSERT `_. """ # noqa params = [key] - self.appendCapacity(params, capacity) - self.appendNoCreate(params, nocreate) - self.appendItems(params, items) + self.append_capacity(params, capacity) + self.append_no_create(params, nocreate) + self.append_items(params, items) return self.execute_command(CF_INSERT, *params) def insertnx(self, key, items, capacity=None, nocreate=None): @@ -220,9 +220,9 @@ def insertnx(self, key, items, capacity=None, nocreate=None): For more information see `CF.INSERTNX `_. """ # noqa params = [key] - self.appendCapacity(params, capacity) - self.appendNoCreate(params, nocreate) - self.appendItems(params, items) + self.append_capacity(params, capacity) + self.append_no_create(params, nocreate) + self.append_items(params, items) return self.execute_command(CF_INSERTNX, *params) def exists(self, key, item): @@ -315,7 +315,7 @@ def incrby(self, key, items, increments): >>> topkincrby('A', ['foo'], [1]) """ # noqa params = [key] - self.appendItemsAndIncrements(params, items, increments) + self.append_items_and_increments(params, items, increments) return self.execute_command(TOPK_INCRBY, *params) def query(self, key, *items): @@ -383,7 +383,7 @@ def add(self, key, values, weights): >>> tdigestadd('A', [1500.0], [1.0]) """ # noqa params = [key] - self.appendValuesAndWeights(params, values, weights) + self.append_values_and_weights(params, values, weights) return self.execute_command(TDIGEST_ADD, *params) def merge(self, toKey, fromKey): @@ -465,7 +465,7 @@ def incrby(self, key, items, increments): >>> cmsincrby('A', ['foo'], [1]) """ # noqa params = [key] - self.appendItemsAndIncrements(params, items, increments) + self.append_items_and_increments(params, items, increments) return self.execute_command(CMS_INCRBY, *params) def query(self, key, *items): @@ -487,7 +487,7 @@ def merge(self, destKey, numKeys, srcKeys, weights=[]): """ # noqa params = [destKey, numKeys] params += srcKeys - self.appendWeights(params, weights) + self.append_weights(params, weights) return self.execute_command(CMS_MERGE, *params) def info(self, key): diff --git a/redis/commands/graph/__init__.py b/redis/commands/graph/__init__.py index 7b9972ad9b..3736195007 100644 --- a/redis/commands/graph/__init__.py +++ b/redis/commands/graph/__init__.py @@ -22,7 +22,7 @@ def __init__(self, client, name=random_string()): self.edges = [] self._labels = [] # List of node labels. self._properties = [] # List of properties. - self._relationshipTypes = [] # List of relation types. + self._relationship_types = [] # List of relation types. self.version = 0 # Graph version @property @@ -32,7 +32,7 @@ def name(self): def _clear_schema(self): self._labels = [] self._properties = [] - self._relationshipTypes = [] + self._relationship_types = [] def _refresh_schema(self): self._clear_schema() @@ -49,15 +49,15 @@ def _refresh_labels(self): self._labels[i] = l[0] def _refresh_relations(self): - rels = self.relationshipTypes() + rels = self.relationship_types() # Unpack data. - self._relationshipTypes = [None] * len(rels) + self._relationship_types = [None] * len(rels) for i, r in enumerate(rels): - self._relationshipTypes[i] = r[0] + self._relationship_types[i] = r[0] def _refresh_attributes(self): - props = self.propertyKeys() + props = self.property_keys() # Unpack data. self._properties = [None] * len(props) @@ -91,11 +91,11 @@ def get_relation(self, idx): The index of the relation """ try: - relationship_type = self._relationshipTypes[idx] + relationship_type = self._relationship_types[idx] except IndexError: # Refresh relationship types. self._refresh_relations() - relationship_type = self._relationshipTypes[idx] + relationship_type = self._relationship_types[idx] return relationship_type def get_property(self, idx): @@ -155,8 +155,8 @@ def call_procedure(self, procedure, *args, read_only=False, **kwagrs): def labels(self): return self.call_procedure("db.labels", read_only=True).result_set - def relationshipTypes(self): + def relationship_types(self): return self.call_procedure("db.relationshipTypes", read_only=True).result_set - def propertyKeys(self): + def property_keys(self): return self.call_procedure("db.propertyKeys", read_only=True).result_set diff --git a/redis/commands/graph/edge.py b/redis/commands/graph/edge.py index b334293fb2..b0141d9452 100644 --- a/redis/commands/graph/edge.py +++ b/redis/commands/graph/edge.py @@ -22,7 +22,7 @@ def __init__(self, src_node, relation, dest_node, edge_id=None, properties=None) self.src_node = src_node self.dest_node = dest_node - def toString(self): + def to_string(self): res = "" if self.properties: props = ",".join( diff --git a/redis/commands/graph/node.py b/redis/commands/graph/node.py index 47e4eeb8e2..c5f842906b 100644 --- a/redis/commands/graph/node.py +++ b/redis/commands/graph/node.py @@ -37,7 +37,7 @@ def __init__(self, node_id=None, alias=None, label=None, properties=None): self.properties = properties or {} - def toString(self): + def to_string(self): res = "" if self.properties: props = ",".join( diff --git a/redis/commands/graph/query_result.py b/redis/commands/graph/query_result.py index e9d9f4d3fd..644ac5a3db 100644 --- a/redis/commands/graph/query_result.py +++ b/redis/commands/graph/query_result.py @@ -292,9 +292,9 @@ def parse_profile(self, response): # record = [] # for idx, cell in enumerate(row): # if type(cell) is Node: - # record.append(cell.toString()) + # record.append(cell.to_string()) # elif type(cell) is Edge: - # record.append(cell.toString()) + # record.append(cell.to_string()) # else: # record.append(cell) # tbl.add_row(record) diff --git a/redis/commands/helpers.py b/redis/commands/helpers.py index afb4f9fae8..2b873e3385 100644 --- a/redis/commands/helpers.py +++ b/redis/commands/helpers.py @@ -117,7 +117,7 @@ def quote_string(v): return f'"{v}"' -def decodeDictKeys(obj): +def decode_dict_keys(obj): """Decode the keys of the given dictionary with utf-8.""" newobj = copy.copy(obj) for k in obj.keys(): diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py index a132b8ee8d..03ab0c4b8d 100644 --- a/redis/commands/json/commands.py +++ b/redis/commands/json/commands.py @@ -12,7 +12,7 @@ class JSONCommands: """json commands.""" - def arrappend(self, name, path=Path.rootPath(), *args): + def arrappend(self, name, path=Path.root_path(), *args): """Append the objects ``args`` to the array under the ``path` in key ``name``. @@ -48,7 +48,7 @@ def arrinsert(self, name, path, index, *args): pieces.append(self._encode(o)) return self.execute_command("JSON.ARRINSERT", *pieces) - def arrlen(self, name, path=Path.rootPath()): + def arrlen(self, name, path=Path.root_path()): """Return the length of the array JSON value under ``path`` at key``name``. @@ -56,7 +56,7 @@ def arrlen(self, name, path=Path.rootPath()): """ # noqa return self.execute_command("JSON.ARRLEN", name, str(path)) - def arrpop(self, name, path=Path.rootPath(), index=-1): + def arrpop(self, name, path=Path.root_path(), index=-1): """Pop the element at ``index`` in the array JSON value under ``path`` at key ``name``. @@ -72,21 +72,21 @@ def arrtrim(self, name, path, start, stop): """ # noqa return self.execute_command("JSON.ARRTRIM", name, str(path), start, stop) - def type(self, name, path=Path.rootPath()): + def type(self, name, path=Path.root_path()): """Get the type of the JSON value under ``path`` from key ``name``. For more information: https://oss.redis.com/redisjson/commands/#jsontype """ # noqa return self.execute_command("JSON.TYPE", name, str(path)) - def resp(self, name, path=Path.rootPath()): + def resp(self, name, path=Path.root_path()): """Return the JSON value under ``path`` at key ``name``. For more information: https://oss.redis.com/redisjson/commands/#jsonresp """ # noqa return self.execute_command("JSON.RESP", name, str(path)) - def objkeys(self, name, path=Path.rootPath()): + def objkeys(self, name, path=Path.root_path()): """Return the key names in the dictionary JSON value under ``path`` at key ``name``. @@ -94,7 +94,7 @@ def objkeys(self, name, path=Path.rootPath()): """ # noqa return self.execute_command("JSON.OBJKEYS", name, str(path)) - def objlen(self, name, path=Path.rootPath()): + def objlen(self, name, path=Path.root_path()): """Return the length of the dictionary JSON value under ``path`` at key ``name``. @@ -123,7 +123,7 @@ def nummultby(self, name, path, number): "JSON.NUMMULTBY", name, str(path), self._encode(number) ) - def clear(self, name, path=Path.rootPath()): + def clear(self, name, path=Path.root_path()): """ Empty arrays and objects (to have zero slots/keys without deleting the array/object). @@ -135,7 +135,7 @@ def clear(self, name, path=Path.rootPath()): """ # noqa return self.execute_command("JSON.CLEAR", name, str(path)) - def delete(self, key, path=Path.rootPath()): + def delete(self, key, path=Path.root_path()): """Delete the JSON value stored at key ``key`` under ``path``. For more information: https://oss.redis.com/redisjson/commands/#jsondel @@ -160,7 +160,7 @@ def get(self, name, *args, no_escape=False): pieces.append("noescape") if len(args) == 0: - pieces.append(Path.rootPath()) + pieces.append(Path.root_path()) else: for p in args: @@ -275,7 +275,7 @@ def strlen(self, name, path=None): pieces.append(str(path)) return self.execute_command("JSON.STRLEN", *pieces) - def toggle(self, name, path=Path.rootPath()): + def toggle(self, name, path=Path.root_path()): """Toggle boolean value under ``path`` at key ``name``. returning the new value. @@ -283,17 +283,17 @@ def toggle(self, name, path=Path.rootPath()): """ # noqa return self.execute_command("JSON.TOGGLE", name, str(path)) - def strappend(self, name, value, path=Path.rootPath()): + def strappend(self, name, value, path=Path.root_path()): """Append to the string JSON value. If two options are specified after the key name, the path is determined to be the first. If a single - option is passed, then the rootpath (i.e Path.rootPath()) is used. + option is passed, then the root_path (i.e Path.root_path()) is used. For more information: https://oss.redis.com/redisjson/commands/#jsonstrappend """ # noqa pieces = [name, str(path), self._encode(value)] return self.execute_command("JSON.STRAPPEND", *pieces) - def debug(self, subcommand, key=None, path=Path.rootPath()): + def debug(self, subcommand, key=None, path=Path.root_path()): """Return the memory usage in bytes of a value under ``path`` from key ``name``. diff --git a/redis/commands/json/path.py b/redis/commands/json/path.py index f0a413a00d..bfb0ab2db0 100644 --- a/redis/commands/json/path.py +++ b/redis/commands/json/path.py @@ -4,7 +4,7 @@ class Path: strPath = "" @staticmethod - def rootPath(): + def root_path(): """Return the root path's string representation.""" return "." diff --git a/redis/commands/search/commands.py b/redis/commands/search/commands.py index 3f768ab320..94edea168c 100644 --- a/redis/commands/search/commands.py +++ b/redis/commands/search/commands.py @@ -447,9 +447,9 @@ def aggregate(self, query): raise ValueError("Bad query", query) raw = self.execute_command(*cmd) - return self._get_AggregateResult(raw, query, has_cursor) + return self._get_aggregate_result(raw, query, has_cursor) - def _get_AggregateResult(self, raw, query, has_cursor): + def _get_aggregate_result(self, raw, query, has_cursor): if has_cursor: if isinstance(query, Cursor): query.cid = raw[1] @@ -499,7 +499,7 @@ def profile(self, query, limited=False): res = self.execute_command(*cmd) if isinstance(query, AggregateRequest): - result = self._get_AggregateResult(res[0], query, query._cursor) + result = self._get_aggregate_result(res[0], query, query._cursor) else: result = Result( res[0], diff --git a/redis/commands/search/indexDefinition.py b/redis/commands/search/indexDefinition.py index 0c7a3b0635..a668e85b42 100644 --- a/redis/commands/search/indexDefinition.py +++ b/redis/commands/search/indexDefinition.py @@ -24,14 +24,14 @@ def __init__( index_type=None, ): self.args = [] - self._appendIndexType(index_type) - self._appendPrefix(prefix) - self._appendFilter(filter) - self._appendLanguage(language_field, language) - self._appendScore(score_field, score) - self._appendPayload(payload_field) + self._append_index_type(index_type) + self._append_prefix(prefix) + self._append_filter(filter) + self._append_language(language_field, language) + self._append_score(score_field, score) + self._append_payload(payload_field) - def _appendIndexType(self, index_type): + def _append_index_type(self, index_type): """Append `ON HASH` or `ON JSON` according to the enum.""" if index_type is IndexType.HASH: self.args.extend(["ON", "HASH"]) @@ -40,7 +40,7 @@ def _appendIndexType(self, index_type): elif index_type is not None: raise RuntimeError(f"index_type must be one of {list(IndexType)}") - def _appendPrefix(self, prefix): + def _append_prefix(self, prefix): """Append PREFIX.""" if len(prefix) > 0: self.args.append("PREFIX") @@ -48,13 +48,13 @@ def _appendPrefix(self, prefix): for p in prefix: self.args.append(p) - def _appendFilter(self, filter): + def _append_filter(self, filter): """Append FILTER.""" if filter is not None: self.args.append("FILTER") self.args.append(filter) - def _appendLanguage(self, language_field, language): + def _append_language(self, language_field, language): """Append LANGUAGE_FIELD and LANGUAGE.""" if language_field is not None: self.args.append("LANGUAGE_FIELD") @@ -63,7 +63,7 @@ def _appendLanguage(self, language_field, language): self.args.append("LANGUAGE") self.args.append(language) - def _appendScore(self, score_field, score): + def _append_score(self, score_field, score): """Append SCORE_FIELD and SCORE.""" if score_field is not None: self.args.append("SCORE_FIELD") @@ -72,7 +72,7 @@ def _appendScore(self, score_field, score): self.args.append("SCORE") self.args.append(score) - def _appendPayload(self, payload_field): + def _append_payload(self, payload_field): """Append PAYLOAD_FIELD.""" if payload_field is not None: self.args.append("PAYLOAD_FIELD") diff --git a/redis/commands/timeseries/commands.py b/redis/commands/timeseries/commands.py index c86e0b98b7..3a30c246d5 100644 --- a/redis/commands/timeseries/commands.py +++ b/redis/commands/timeseries/commands.py @@ -66,11 +66,11 @@ def create(self, key, **kwargs): chunk_size = kwargs.get("chunk_size", None) duplicate_policy = kwargs.get("duplicate_policy", None) params = [key] - self._appendRetention(params, retention_msecs) - self._appendUncompressed(params, uncompressed) - self._appendChunkSize(params, chunk_size) - self._appendDuplicatePolicy(params, CREATE_CMD, duplicate_policy) - self._appendLabels(params, labels) + self._append_retention(params, retention_msecs) + self._append_uncompressed(params, uncompressed) + self._append_chunk_size(params, chunk_size) + self._append_duplicate_policy(params, CREATE_CMD, duplicate_policy) + self._append_labels(params, labels) return self.execute_command(CREATE_CMD, *params) @@ -87,9 +87,9 @@ def alter(self, key, **kwargs): labels = kwargs.get("labels", {}) duplicate_policy = kwargs.get("duplicate_policy", None) params = [key] - self._appendRetention(params, retention_msecs) - self._appendDuplicatePolicy(params, ALTER_CMD, duplicate_policy) - self._appendLabels(params, labels) + self._append_retention(params, retention_msecs) + self._append_duplicate_policy(params, ALTER_CMD, duplicate_policy) + self._append_labels(params, labels) return self.execute_command(ALTER_CMD, *params) @@ -137,11 +137,11 @@ def add(self, key, timestamp, value, **kwargs): chunk_size = kwargs.get("chunk_size", None) duplicate_policy = kwargs.get("duplicate_policy", None) params = [key, timestamp, value] - self._appendRetention(params, retention_msecs) - self._appendUncompressed(params, uncompressed) - self._appendChunkSize(params, chunk_size) - self._appendDuplicatePolicy(params, ADD_CMD, duplicate_policy) - self._appendLabels(params, labels) + self._append_retention(params, retention_msecs) + self._append_uncompressed(params, uncompressed) + self._append_chunk_size(params, chunk_size) + self._append_duplicate_policy(params, ADD_CMD, duplicate_policy) + self._append_labels(params, labels) return self.execute_command(ADD_CMD, *params) @@ -197,11 +197,11 @@ def incrby(self, key, value, **kwargs): labels = kwargs.get("labels", {}) chunk_size = kwargs.get("chunk_size", None) params = [key, value] - self._appendTimestamp(params, timestamp) - self._appendRetention(params, retention_msecs) - self._appendUncompressed(params, uncompressed) - self._appendChunkSize(params, chunk_size) - self._appendLabels(params, labels) + self._append_timestamp(params, timestamp) + self._append_retention(params, retention_msecs) + self._append_uncompressed(params, uncompressed) + self._append_chunk_size(params, chunk_size) + self._append_labels(params, labels) return self.execute_command(INCRBY_CMD, *params) @@ -245,11 +245,11 @@ def decrby(self, key, value, **kwargs): labels = kwargs.get("labels", {}) chunk_size = kwargs.get("chunk_size", None) params = [key, value] - self._appendTimestamp(params, timestamp) - self._appendRetention(params, retention_msecs) - self._appendUncompressed(params, uncompressed) - self._appendChunkSize(params, chunk_size) - self._appendLabels(params, labels) + self._append_timestamp(params, timestamp) + self._append_retention(params, retention_msecs) + self._append_uncompressed(params, uncompressed) + self._append_chunk_size(params, chunk_size) + self._append_labels(params, labels) return self.execute_command(DECRBY_CMD, *params) @@ -285,7 +285,7 @@ def createrule(self, source_key, dest_key, aggregation_type, bucket_size_msec): For more information: https://oss.redis.com/redistimeseries/master/commands/#tscreaterule """ # noqa params = [source_key, dest_key] - self._appendAggregation(params, aggregation_type, bucket_size_msec) + self._append_aggregation(params, aggregation_type, bucket_size_msec) return self.execute_command(CREATERULE_CMD, *params) @@ -313,11 +313,11 @@ def __range_params( ): """Create TS.RANGE and TS.REVRANGE arguments.""" params = [key, from_time, to_time] - self._appendFilerByTs(params, filter_by_ts) - self._appendFilerByValue(params, filter_by_min_value, filter_by_max_value) - self._appendCount(params, count) - self._appendAlign(params, align) - self._appendAggregation(params, aggregation_type, bucket_size_msec) + self._append_filer_by_ts(params, filter_by_ts) + self._append_filer_by_value(params, filter_by_min_value, filter_by_max_value) + self._append_count(params, count) + self._append_align(params, align) + self._append_aggregation(params, aggregation_type, bucket_size_msec) return params @@ -459,15 +459,15 @@ def __mrange_params( ): """Create TS.MRANGE and TS.MREVRANGE arguments.""" params = [from_time, to_time] - self._appendFilerByTs(params, filter_by_ts) - self._appendFilerByValue(params, filter_by_min_value, filter_by_max_value) - self._appendCount(params, count) - self._appendAlign(params, align) - self._appendAggregation(params, aggregation_type, bucket_size_msec) - self._appendWithLabels(params, with_labels, select_labels) + self._append_filer_by_ts(params, filter_by_ts) + self._append_filer_by_value(params, filter_by_min_value, filter_by_max_value) + self._append_count(params, count) + self._append_align(params, align) + self._append_aggregation(params, aggregation_type, bucket_size_msec) + self._append_with_labels(params, with_labels, select_labels) params.extend(["FILTER"]) params += filters - self._appendGroupbyReduce(params, groupby, reduce) + self._append_groupby_reduce(params, groupby, reduce) return params def mrange( @@ -653,7 +653,7 @@ def mget(self, filters, with_labels=False): For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmget """ # noqa params = [] - self._appendWithLabels(params, with_labels) + self._append_with_labels(params, with_labels) params.extend(["FILTER"]) params += filters return self.execute_command(MGET_CMD, *params) @@ -675,13 +675,13 @@ def queryindex(self, filters): return self.execute_command(QUERYINDEX_CMD, *filters) @staticmethod - def _appendUncompressed(params, uncompressed): + def _append_uncompressed(params, uncompressed): """Append UNCOMPRESSED tag to params.""" if uncompressed: params.extend(["UNCOMPRESSED"]) @staticmethod - def _appendWithLabels(params, with_labels, select_labels=None): + def _append_with_labels(params, with_labels, select_labels=None): """Append labels behavior to params.""" if with_labels and select_labels: raise DataError( @@ -694,19 +694,19 @@ def _appendWithLabels(params, with_labels, select_labels=None): params.extend(["SELECTED_LABELS", *select_labels]) @staticmethod - def _appendGroupbyReduce(params, groupby, reduce): + def _append_groupby_reduce(params, groupby, reduce): """Append GROUPBY REDUCE property to params.""" if groupby is not None and reduce is not None: params.extend(["GROUPBY", groupby, "REDUCE", reduce.upper()]) @staticmethod - def _appendRetention(params, retention): + def _append_retention(params, retention): """Append RETENTION property to params.""" if retention is not None: params.extend(["RETENTION", retention]) @staticmethod - def _appendLabels(params, labels): + def _append_labels(params, labels): """Append LABELS property to params.""" if labels: params.append("LABELS") @@ -714,38 +714,38 @@ def _appendLabels(params, labels): params.extend([k, v]) @staticmethod - def _appendCount(params, count): + def _append_count(params, count): """Append COUNT property to params.""" if count is not None: params.extend(["COUNT", count]) @staticmethod - def _appendTimestamp(params, timestamp): + def _append_timestamp(params, timestamp): """Append TIMESTAMP property to params.""" if timestamp is not None: params.extend(["TIMESTAMP", timestamp]) @staticmethod - def _appendAlign(params, align): + def _append_align(params, align): """Append ALIGN property to params.""" if align is not None: params.extend(["ALIGN", align]) @staticmethod - def _appendAggregation(params, aggregation_type, bucket_size_msec): + def _append_aggregation(params, aggregation_type, bucket_size_msec): """Append AGGREGATION property to params.""" if aggregation_type is not None: params.append("AGGREGATION") params.extend([aggregation_type, bucket_size_msec]) @staticmethod - def _appendChunkSize(params, chunk_size): + def _append_chunk_size(params, chunk_size): """Append CHUNK_SIZE property to params.""" if chunk_size is not None: params.extend(["CHUNK_SIZE", chunk_size]) @staticmethod - def _appendDuplicatePolicy(params, command, duplicate_policy): + def _append_duplicate_policy(params, command, duplicate_policy): """Append DUPLICATE_POLICY property to params on CREATE and ON_DUPLICATE on ADD. """ @@ -756,13 +756,13 @@ def _appendDuplicatePolicy(params, command, duplicate_policy): params.extend(["DUPLICATE_POLICY", duplicate_policy]) @staticmethod - def _appendFilerByTs(params, ts_list): + def _append_filer_by_ts(params, ts_list): """Append FILTER_BY_TS property to params.""" if ts_list is not None: params.extend(["FILTER_BY_TS", *ts_list]) @staticmethod - def _appendFilerByValue(params, min_value, max_value): + def _append_filer_by_value(params, min_value, max_value): """Append FILTER_BY_VALUE property to params.""" if min_value is not None and max_value is not None: params.extend(["FILTER_BY_VALUE", min_value, max_value]) diff --git a/tests/test_graph.py b/tests/test_graph.py index c6dc9a4371..2125d4a2fc 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -440,13 +440,13 @@ def test_cache_sync(client): assert len(A._labels) == 2 assert len(A._properties) == 2 - assert len(A._relationshipTypes) == 2 + assert len(A._relationship_types) == 2 assert A._labels[0] == "L" assert A._labels[1] == "K" assert A._properties[0] == "x" assert A._properties[1] == "q" - assert A._relationshipTypes[0] == "R" - assert A._relationshipTypes[1] == "S" + assert A._relationship_types[0] == "R" + assert A._relationship_types[1] == "S" # Have client B reconstruct the graph in a different order. B.delete() @@ -468,10 +468,10 @@ def test_cache_sync(client): assert len(A._labels) == 2 assert len(A._properties) == 2 - assert len(A._relationshipTypes) == 2 + assert len(A._relationship_types) == 2 assert A._labels[0] == "K" assert A._labels[1] == "L" assert A._properties[0] == "q" assert A._properties[1] == "x" - assert A._relationshipTypes[0] == "S" - assert A._relationshipTypes[1] == "R" + assert A._relationship_types[0] == "S" + assert A._relationship_types[1] == "R" diff --git a/tests/test_graph_utils/test_edge.py b/tests/test_graph_utils/test_edge.py index 42358de19a..b5b7362389 100644 --- a/tests/test_graph_utils/test_edge.py +++ b/tests/test_graph_utils/test_edge.py @@ -17,15 +17,15 @@ def test_init(): @pytest.mark.redismod -def test_toString(): +def test_to_string(): props_result = edge.Edge( node.Node(), None, node.Node(), properties={"a": "a", "b": 10} - ).toString() + ).to_string() assert props_result == '{a:"a",b:10}' no_props_result = edge.Edge( node.Node(), None, node.Node(), properties={} - ).toString() + ).to_string() assert no_props_result == "" diff --git a/tests/test_graph_utils/test_node.py b/tests/test_graph_utils/test_node.py index faf8ab6458..cd4e936719 100644 --- a/tests/test_graph_utils/test_node.py +++ b/tests/test_graph_utils/test_node.py @@ -14,13 +14,13 @@ def fixture(): @pytest.mark.redismod -def test_toString(fixture): +def test_to_string(fixture): no_args, no_props, props_only, no_label, multi_label = fixture - assert no_args.toString() == "" - assert no_props.toString() == "" - assert props_only.toString() == '{a:"a",b:10}' - assert no_label.toString() == '{a:"a"}' - assert multi_label.toString() == "" + assert no_args.to_string() == "" + assert no_props.to_string() == "" + assert props_only.to_string() == '{a:"a",b:10}' + assert no_label.to_string() == '{a:"a"}' + assert multi_label.to_string() == "" @pytest.mark.redismod diff --git a/tests/test_json.py b/tests/test_json.py index 21bdc08b5e..3d9b67841f 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -18,13 +18,13 @@ def client(modclient): def test_json_setbinarykey(client): d = {"hello": "world", b"some": "value"} with pytest.raises(TypeError): - client.json().set("somekey", Path.rootPath(), d) - assert client.json().set("somekey", Path.rootPath(), d, decode_keys=True) + client.json().set("somekey", Path.root_path(), d) + assert client.json().set("somekey", Path.root_path(), d, decode_keys=True) @pytest.mark.redismod def test_json_setgetdeleteforget(client): - assert client.json().set("foo", Path.rootPath(), "bar") + assert client.json().set("foo", Path.root_path(), "bar") assert client.json().get("foo") == "bar" assert client.json().get("baz") is None assert client.json().delete("foo") == 1 @@ -34,13 +34,13 @@ def test_json_setgetdeleteforget(client): @pytest.mark.redismod def test_jsonget(client): - client.json().set("foo", Path.rootPath(), "bar") + client.json().set("foo", Path.root_path(), "bar") assert client.json().get("foo") == "bar" @pytest.mark.redismod def test_json_get_jset(client): - assert client.json().set("foo", Path.rootPath(), "bar") + assert client.json().set("foo", Path.root_path(), "bar") assert "bar" == client.json().get("foo") assert client.json().get("baz") is None assert 1 == client.json().delete("foo") @@ -49,7 +49,7 @@ def test_json_get_jset(client): @pytest.mark.redismod def test_nonascii_setgetdelete(client): - assert client.json().set("notascii", Path.rootPath(), "hyvää-élève") + assert client.json().set("notascii", Path.root_path(), "hyvää-élève") assert "hyvää-élève" == client.json().get("notascii", no_escape=True) assert 1 == client.json().delete("notascii") assert client.exists("notascii") == 0 @@ -58,7 +58,7 @@ def test_nonascii_setgetdelete(client): @pytest.mark.redismod def test_jsonsetexistentialmodifiersshouldsucceed(client): obj = {"foo": "bar"} - assert client.json().set("obj", Path.rootPath(), obj) + assert client.json().set("obj", Path.root_path(), obj) # Test that flags prevent updates when conditions are unmet assert client.json().set("obj", Path("foo"), "baz", nx=True) is None @@ -75,69 +75,69 @@ def test_jsonsetexistentialmodifiersshouldsucceed(client): @pytest.mark.redismod def test_mgetshouldsucceed(client): - client.json().set("1", Path.rootPath(), 1) - client.json().set("2", Path.rootPath(), 2) - assert client.json().mget(["1"], Path.rootPath()) == [1] + client.json().set("1", Path.root_path(), 1) + client.json().set("2", Path.root_path(), 2) + assert client.json().mget(["1"], Path.root_path()) == [1] - assert client.json().mget([1, 2], Path.rootPath()) == [1, 2] + assert client.json().mget([1, 2], Path.root_path()) == [1, 2] @pytest.mark.redismod @skip_ifmodversion_lt("99.99.99", "ReJSON") # todo: update after the release def test_clear(client): - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 1 == client.json().clear("arr", Path.rootPath()) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 1 == client.json().clear("arr", Path.root_path()) assert [] == client.json().get("arr") @pytest.mark.redismod def test_type(client): - client.json().set("1", Path.rootPath(), 1) - assert "integer" == client.json().type("1", Path.rootPath()) + client.json().set("1", Path.root_path(), 1) + assert "integer" == client.json().type("1", Path.root_path()) assert "integer" == client.json().type("1") @pytest.mark.redismod def test_numincrby(client): - client.json().set("num", Path.rootPath(), 1) - assert 2 == client.json().numincrby("num", Path.rootPath(), 1) - assert 2.5 == client.json().numincrby("num", Path.rootPath(), 0.5) - assert 1.25 == client.json().numincrby("num", Path.rootPath(), -1.25) + client.json().set("num", Path.root_path(), 1) + assert 2 == client.json().numincrby("num", Path.root_path(), 1) + assert 2.5 == client.json().numincrby("num", Path.root_path(), 0.5) + assert 1.25 == client.json().numincrby("num", Path.root_path(), -1.25) @pytest.mark.redismod def test_nummultby(client): - client.json().set("num", Path.rootPath(), 1) + client.json().set("num", Path.root_path(), 1) with pytest.deprecated_call(): - assert 2 == client.json().nummultby("num", Path.rootPath(), 2) - assert 5 == client.json().nummultby("num", Path.rootPath(), 2.5) - assert 2.5 == client.json().nummultby("num", Path.rootPath(), 0.5) + assert 2 == client.json().nummultby("num", Path.root_path(), 2) + assert 5 == client.json().nummultby("num", Path.root_path(), 2.5) + assert 2.5 == client.json().nummultby("num", Path.root_path(), 0.5) @pytest.mark.redismod @skip_ifmodversion_lt("99.99.99", "ReJSON") # todo: update after the release def test_toggle(client): - client.json().set("bool", Path.rootPath(), False) - assert client.json().toggle("bool", Path.rootPath()) - assert client.json().toggle("bool", Path.rootPath()) is False + client.json().set("bool", Path.root_path(), False) + assert client.json().toggle("bool", Path.root_path()) + assert client.json().toggle("bool", Path.root_path()) is False # check non-boolean value - client.json().set("num", Path.rootPath(), 1) + client.json().set("num", Path.root_path(), 1) with pytest.raises(redis.exceptions.ResponseError): - client.json().toggle("num", Path.rootPath()) + client.json().toggle("num", Path.root_path()) @pytest.mark.redismod def test_strappend(client): - client.json().set("jsonkey", Path.rootPath(), "foo") + client.json().set("jsonkey", Path.root_path(), "foo") assert 6 == client.json().strappend("jsonkey", "bar") - assert "foobar" == client.json().get("jsonkey", Path.rootPath()) + assert "foobar" == client.json().get("jsonkey", Path.root_path()) # @pytest.mark.redismod # def test_debug(client): -# client.json().set("str", Path.rootPath(), "foo") -# assert 24 == client.json().debug("MEMORY", "str", Path.rootPath()) +# client.json().set("str", Path.root_path(), "foo") +# assert 24 == client.json().debug("MEMORY", "str", Path.root_path()) # assert 24 == client.json().debug("MEMORY", "str") # # # technically help is valid @@ -146,34 +146,34 @@ def test_strappend(client): @pytest.mark.redismod def test_strlen(client): - client.json().set("str", Path.rootPath(), "foo") - assert 3 == client.json().strlen("str", Path.rootPath()) - client.json().strappend("str", "bar", Path.rootPath()) - assert 6 == client.json().strlen("str", Path.rootPath()) + client.json().set("str", Path.root_path(), "foo") + assert 3 == client.json().strlen("str", Path.root_path()) + client.json().strappend("str", "bar", Path.root_path()) + assert 6 == client.json().strlen("str", Path.root_path()) assert 6 == client.json().strlen("str") @pytest.mark.redismod def test_arrappend(client): - client.json().set("arr", Path.rootPath(), [1]) - assert 2 == client.json().arrappend("arr", Path.rootPath(), 2) - assert 4 == client.json().arrappend("arr", Path.rootPath(), 3, 4) - assert 7 == client.json().arrappend("arr", Path.rootPath(), *[5, 6, 7]) + client.json().set("arr", Path.root_path(), [1]) + assert 2 == client.json().arrappend("arr", Path.root_path(), 2) + assert 4 == client.json().arrappend("arr", Path.root_path(), 3, 4) + assert 7 == client.json().arrappend("arr", Path.root_path(), *[5, 6, 7]) @pytest.mark.redismod def test_arrindex(client): - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 1 == client.json().arrindex("arr", Path.rootPath(), 1) - assert -1 == client.json().arrindex("arr", Path.rootPath(), 1, 2) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 1 == client.json().arrindex("arr", Path.root_path(), 1) + assert -1 == client.json().arrindex("arr", Path.root_path(), 1, 2) @pytest.mark.redismod def test_arrinsert(client): - client.json().set("arr", Path.rootPath(), [0, 4]) + client.json().set("arr", Path.root_path(), [0, 4]) assert 5 - -client.json().arrinsert( "arr", - Path.rootPath(), + Path.root_path(), 1, *[ 1, @@ -184,64 +184,64 @@ def test_arrinsert(client): assert [0, 1, 2, 3, 4] == client.json().get("arr") # test prepends - client.json().set("val2", Path.rootPath(), [5, 6, 7, 8, 9]) - client.json().arrinsert("val2", Path.rootPath(), 0, ["some", "thing"]) + client.json().set("val2", Path.root_path(), [5, 6, 7, 8, 9]) + client.json().arrinsert("val2", Path.root_path(), 0, ["some", "thing"]) assert client.json().get("val2") == [["some", "thing"], 5, 6, 7, 8, 9] @pytest.mark.redismod def test_arrlen(client): - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 5 == client.json().arrlen("arr", Path.rootPath()) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 5 == client.json().arrlen("arr", Path.root_path()) assert 5 == client.json().arrlen("arr") assert client.json().arrlen("fakekey") is None @pytest.mark.redismod def test_arrpop(client): - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 4 == client.json().arrpop("arr", Path.rootPath(), 4) - assert 3 == client.json().arrpop("arr", Path.rootPath(), -1) - assert 2 == client.json().arrpop("arr", Path.rootPath()) - assert 0 == client.json().arrpop("arr", Path.rootPath(), 0) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 4 == client.json().arrpop("arr", Path.root_path(), 4) + assert 3 == client.json().arrpop("arr", Path.root_path(), -1) + assert 2 == client.json().arrpop("arr", Path.root_path()) + assert 0 == client.json().arrpop("arr", Path.root_path(), 0) assert [1] == client.json().get("arr") # test out of bounds - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 4 == client.json().arrpop("arr", Path.rootPath(), 99) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 4 == client.json().arrpop("arr", Path.root_path(), 99) # none test - client.json().set("arr", Path.rootPath(), []) + client.json().set("arr", Path.root_path(), []) assert client.json().arrpop("arr") is None @pytest.mark.redismod def test_arrtrim(client): - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 3 == client.json().arrtrim("arr", Path.rootPath(), 1, 3) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 3 == client.json().arrtrim("arr", Path.root_path(), 1, 3) assert [1, 2, 3] == client.json().get("arr") # <0 test, should be 0 equivalent - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 0 == client.json().arrtrim("arr", Path.rootPath(), -1, 3) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 0 == client.json().arrtrim("arr", Path.root_path(), -1, 3) # testing stop > end - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 2 == client.json().arrtrim("arr", Path.rootPath(), 3, 99) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 2 == client.json().arrtrim("arr", Path.root_path(), 3, 99) # start > array size and stop - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 0 == client.json().arrtrim("arr", Path.rootPath(), 9, 1) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 1) # all larger - client.json().set("arr", Path.rootPath(), [0, 1, 2, 3, 4]) - assert 0 == client.json().arrtrim("arr", Path.rootPath(), 9, 11) + client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) + assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 11) @pytest.mark.redismod def test_resp(client): obj = {"foo": "bar", "baz": 1, "qaz": True} - client.json().set("obj", Path.rootPath(), obj) + client.json().set("obj", Path.root_path(), obj) assert "bar" == client.json().resp("obj", Path("foo")) assert 1 == client.json().resp("obj", Path("baz")) assert client.json().resp("obj", Path("qaz")) @@ -251,14 +251,14 @@ def test_resp(client): @pytest.mark.redismod def test_objkeys(client): obj = {"foo": "bar", "baz": "qaz"} - client.json().set("obj", Path.rootPath(), obj) - keys = client.json().objkeys("obj", Path.rootPath()) + client.json().set("obj", Path.root_path(), obj) + keys = client.json().objkeys("obj", Path.root_path()) keys.sort() exp = list(obj.keys()) exp.sort() assert exp == keys - client.json().set("obj", Path.rootPath(), obj) + client.json().set("obj", Path.root_path(), obj) keys = client.json().objkeys("obj") assert keys == list(obj.keys()) @@ -268,17 +268,17 @@ def test_objkeys(client): @pytest.mark.redismod def test_objlen(client): obj = {"foo": "bar", "baz": "qaz"} - client.json().set("obj", Path.rootPath(), obj) - assert len(obj) == client.json().objlen("obj", Path.rootPath()) + client.json().set("obj", Path.root_path(), obj) + assert len(obj) == client.json().objlen("obj", Path.root_path()) - client.json().set("obj", Path.rootPath(), obj) + client.json().set("obj", Path.root_path(), obj) assert len(obj) == client.json().objlen("obj") @pytest.mark.redismod def test_json_commands_in_pipeline(client): p = client.json().pipeline() - p.set("foo", Path.rootPath(), "bar") + p.set("foo", Path.root_path(), "bar") p.get("foo") p.delete("foo") assert [True, "bar", 1] == p.execute() @@ -290,7 +290,7 @@ def test_json_commands_in_pipeline(client): p = client.json().pipeline() d = {"hello": "world", "oh": "snap"} with pytest.deprecated_call(): - p.jsonset("foo", Path.rootPath(), d) + p.jsonset("foo", Path.root_path(), d) p.jsonget("foo") p.exists("notarealkey") p.delete("foo") @@ -1385,7 +1385,7 @@ def test_custom_decoder(client): import ujson cj = client.json(encoder=ujson, decoder=ujson) - assert cj.set("foo", Path.rootPath(), "bar") + assert cj.set("foo", Path.root_path(), "bar") assert "bar" == cj.get("foo") assert cj.get("baz") is None assert 1 == cj.delete("foo") @@ -1407,10 +1407,10 @@ def test_set_file(client): nojsonfile = tempfile.NamedTemporaryFile() nojsonfile.write(b"Hello World") - assert client.json().set_file("test", Path.rootPath(), jsonfile.name) + assert client.json().set_file("test", Path.root_path(), jsonfile.name) assert client.json().get("test") == obj with pytest.raises(json.JSONDecodeError): - client.json().set_file("test2", Path.rootPath(), nojsonfile.name) + client.json().set_file("test2", Path.root_path(), nojsonfile.name) @pytest.mark.redismod @@ -1428,5 +1428,5 @@ def test_set_path(client): open(nojsonfile, "a+").write("hello") result = {jsonfile: True, nojsonfile: False} - assert client.json().set_path(Path.rootPath(), root) == result + assert client.json().set_path(Path.root_path(), root) == result assert client.json().get(jsonfile.rsplit(".")[0]) == {"hello": "world"} diff --git a/tests/test_search.py b/tests/test_search.py index 6c79041cfe..18bb9adecf 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1266,8 +1266,8 @@ def test_create_client_definition_json(client): definition = IndexDefinition(prefix=["king:"], index_type=IndexType.JSON) client.ft().create_index((TextField("$.name"),), definition=definition) - client.json().set("king:1", Path.rootPath(), {"name": "henry"}) - client.json().set("king:2", Path.rootPath(), {"name": "james"}) + client.json().set("king:1", Path.root_path(), {"name": "henry"}) + client.json().set("king:2", Path.root_path(), {"name": "james"}) res = client.ft().search("henry") assert res.docs[0].id == "king:1" @@ -1288,7 +1288,7 @@ def test_fields_as_name(client): client.ft().create_index(SCHEMA, definition=definition) # insert json data - res = client.json().set("doc:1", Path.rootPath(), {"name": "Jon", "age": 25}) + res = client.json().set("doc:1", Path.root_path(), {"name": "Jon", "age": 25}) assert res total = client.ft().search(Query("Jon").return_fields("name", "just_a_number")).docs @@ -1303,7 +1303,7 @@ def test_fields_as_name(client): def test_search_return_fields(client): res = client.json().set( "doc:1", - Path.rootPath(), + Path.root_path(), {"t": "riceratops", "t2": "telmatosaurus", "n": 9072, "flt": 97.2}, ) assert res @@ -1389,8 +1389,8 @@ def test_create_json_with_alias(client): definition=definition, ) - client.json().set("king:1", Path.rootPath(), {"name": "henry", "num": 42}) - client.json().set("king:2", Path.rootPath(), {"name": "james", "num": 3.14}) + client.json().set("king:1", Path.root_path(), {"name": "henry", "num": 42}) + client.json().set("king:2", Path.root_path(), {"name": "james", "num": 3.14}) res = client.ft().search("@name:henry") assert res.docs[0].id == "king:1" @@ -1421,7 +1421,7 @@ def test_json_with_multipath(client): ) client.json().set( - "king:1", Path.rootPath(), {"name": "henry", "country": {"name": "england"}} + "king:1", Path.root_path(), {"name": "henry", "country": {"name": "england"}} ) res = client.ft().search("@name:{henry}") @@ -1447,7 +1447,7 @@ def test_json_with_jsonpath(client): definition=definition, ) - client.json().set("doc:1", Path.rootPath(), {"prod:name": "RediSearch"}) + client.json().set("doc:1", Path.root_path(), {"prod:name": "RediSearch"}) # query for a supported field succeeds res = client.ft().search(Query("@name:RediSearch"))