diff --git a/python/python/glide/__init__.py b/python/python/glide/__init__.py index 9e3d808a8c..541d907023 100644 --- a/python/python/glide/__init__.py +++ b/python/python/glide/__init__.py @@ -33,7 +33,7 @@ OnlyIfEqual, UpdateOptions, ) -from glide.async_commands.server_modules import ft, glide_json, json_transaction +from glide.async_commands.server_modules import ft, glide_json, json_batch from glide.async_commands.server_modules.ft_options.ft_aggregate_options import ( FtAggregateApply, FtAggregateClause, @@ -273,7 +273,7 @@ "PubSubMsg", # Json "glide_json", - "json_transaction", + "json_batch", "JsonGetOptions", "JsonArrIndexOptions", "JsonArrPopOptions", diff --git a/python/python/glide/async_commands/server_modules/json_transaction.py b/python/python/glide/async_commands/server_modules/json_batch.py similarity index 99% rename from python/python/glide/async_commands/server_modules/json_transaction.py rename to python/python/glide/async_commands/server_modules/json_batch.py index ad0cc91158..08608be2eb 100644 --- a/python/python/glide/async_commands/server_modules/json_transaction.py +++ b/python/python/glide/async_commands/server_modules/json_batch.py @@ -3,12 +3,12 @@ Examples: >>> import json - >>> from glide import json_transaction + >>> from glide import json_batch >>> transaction = ClusterTransaction() >>> value = {'a': 1.0, 'b': 2} >>> json_str = json.dumps(value) # Convert Python dictionary to JSON string using json.dumps() - >>> json_transaction.set(transaction, "doc", "$", json_str) - >>> json_transaction.get(transaction, "doc", "$") # Returns the value at path '$' in the JSON document stored at `doc` as JSON string. + >>> json_batch.set(transaction, "doc", "$", json_str) + >>> json_batch.get(transaction, "doc", "$") # Returns the value at path '$' in the JSON document stored at `doc` as JSON string. >>> result = await glide_client.exec(transaction) >>> print result[0] # set result 'OK' # Indicates successful setting of the value at path '$' in the key stored at `doc`. diff --git a/python/python/tests/tests_server_modules/test_json.py b/python/python/tests/tests_server_modules/test_json.py index 0182943d82..207a48826c 100644 --- a/python/python/tests/tests_server_modules/test_json.py +++ b/python/python/tests/tests_server_modules/test_json.py @@ -9,7 +9,7 @@ import pytest from glide.async_commands.core import ConditionalChange, InfoSection from glide.async_commands.server_modules import glide_json as json -from glide.async_commands.server_modules import json_transaction +from glide.async_commands.server_modules import json_batch from glide.async_commands.server_modules.glide_json import ( JsonArrIndexOptions, JsonArrPopOptions, @@ -2107,7 +2107,7 @@ async def test_json_arrpop(self, glide_client: TGlideClient): @pytest.mark.parametrize("cluster_mode", [True]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_json_transaction_array(self, glide_client: GlideClusterClient): + async def test_json_batch_array(self, glide_client: GlideClusterClient): transaction = ClusterTransaction() key = get_random_string(5) @@ -2115,22 +2115,20 @@ async def test_json_transaction_array(self, glide_client: GlideClusterClient): json_value2 = {"a": 1.0, "b": [1, 2]} # Test 'set', 'get', and 'clear' commands - json_transaction.set(transaction, key, "$", OuterJson.dumps(json_value1)) - json_transaction.clear(transaction, key, "$") - json_transaction.set(transaction, key, "$", OuterJson.dumps(json_value1)) - json_transaction.get(transaction, key, ".") + json_batch.set(transaction, key, "$", OuterJson.dumps(json_value1)) + json_batch.clear(transaction, key, "$") + json_batch.set(transaction, key, "$", OuterJson.dumps(json_value1)) + json_batch.get(transaction, key, ".") # Test array related commands - json_transaction.set(transaction, key, "$", OuterJson.dumps(json_value2)) - json_transaction.arrappend(transaction, key, "$.b", ["3", "4"]) - json_transaction.arrindex(transaction, key, "$.b", "2") - json_transaction.arrinsert(transaction, key, "$.b", 2, ["5"]) - json_transaction.arrlen(transaction, key, "$.b") - json_transaction.arrpop( - transaction, key, JsonArrPopOptions(path="$.b", index=2) - ) - json_transaction.arrtrim(transaction, key, "$.b", 1, 2) - json_transaction.get(transaction, key, ".") + json_batch.set(transaction, key, "$", OuterJson.dumps(json_value2)) + json_batch.arrappend(transaction, key, "$.b", ["3", "4"]) + json_batch.arrindex(transaction, key, "$.b", "2") + json_batch.arrinsert(transaction, key, "$.b", 2, ["5"]) + json_batch.arrlen(transaction, key, "$.b") + json_batch.arrpop(transaction, key, JsonArrPopOptions(path="$.b", index=2)) + json_batch.arrtrim(transaction, key, "$.b", 1, 2) + json_batch.get(transaction, key, ".") result = await glide_client.exec(transaction) assert isinstance(result, list) @@ -2153,7 +2151,7 @@ async def test_json_transaction_array(self, glide_client: GlideClusterClient): @pytest.mark.parametrize("cluster_mode", [True]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_json_transaction(self, glide_client: GlideClusterClient): + async def test_json_batch(self, glide_client: GlideClusterClient): transaction = ClusterTransaction() key = f"{{key}}-1{get_random_string(5)}" @@ -2161,43 +2159,43 @@ async def test_json_transaction(self, glide_client: GlideClusterClient): key3 = f"{{key}}-3{get_random_string(5)}" json_value = {"a": [1, 2], "b": [3, 4], "c": "c", "d": True} - json_transaction.set(transaction, key, "$", OuterJson.dumps(json_value)) + json_batch.set(transaction, key, "$", OuterJson.dumps(json_value)) # Test debug commands - json_transaction.debug_memory(transaction, key, "$.a") - json_transaction.debug_fields(transaction, key, "$.a") + json_batch.debug_memory(transaction, key, "$.a") + json_batch.debug_fields(transaction, key, "$.a") # Test obj commands - json_transaction.objlen(transaction, key, ".") - json_transaction.objkeys(transaction, key, ".") + json_batch.objlen(transaction, key, ".") + json_batch.objkeys(transaction, key, ".") # Test num commands - json_transaction.numincrby(transaction, key, "$.a[*]", 10.0) - json_transaction.nummultby(transaction, key, "$.a[*]", 10.0) + json_batch.numincrby(transaction, key, "$.a[*]", 10.0) + json_batch.nummultby(transaction, key, "$.a[*]", 10.0) # Test str commands - json_transaction.strappend(transaction, key, '"-test"', "$.c") - json_transaction.strlen(transaction, key, "$.c") + json_batch.strappend(transaction, key, '"-test"', "$.c") + json_batch.strlen(transaction, key, "$.c") # Test type command - json_transaction.type(transaction, key, "$.a") + json_batch.type(transaction, key, "$.a") # Test mget command json_value2 = {"b": [3, 4], "c": "c", "d": True} - json_transaction.set(transaction, key2, "$", OuterJson.dumps(json_value2)) - json_transaction.mget(transaction, [key, key2, key3], "$.a") + json_batch.set(transaction, key2, "$", OuterJson.dumps(json_value2)) + json_batch.mget(transaction, [key, key2, key3], "$.a") # Test toggle command - json_transaction.toggle(transaction, key, "$.d") + json_batch.toggle(transaction, key, "$.d") # Test resp command - json_transaction.resp(transaction, key, "$") + json_batch.resp(transaction, key, "$") # Test del command - json_transaction.delete(transaction, key, "$.d") + json_batch.delete(transaction, key, "$.d") # Test forget command - json_transaction.forget(transaction, key, "$.c") + json_batch.forget(transaction, key, "$.c") result = await glide_client.exec(transaction) assert isinstance(result, list)