Skip to content

Commit d6849e3

Browse files
committed
PR Cleanup
1 parent d823f90 commit d6849e3

File tree

7 files changed

+11
-18
lines changed

7 files changed

+11
-18
lines changed

key-value/key-value-aio/src/key_value/aio/stores/elasticsearch/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class InstallSerializerMixin:
121121

122122
@classmethod
123123
def install_serializer(cls, client: AsyncElasticsearch) -> None:
124-
client._transport.serializers.serializers.update(
124+
client.transport.serializers.serializers.update(
125125
{
126126
cls.mimetype: cls(),
127127
cls.compatibility_mimetype: cls(),
@@ -131,7 +131,7 @@ def install_serializer(cls, client: AsyncElasticsearch) -> None:
131131
@classmethod
132132
def install_default_serializer(cls, client: AsyncElasticsearch) -> None:
133133
cls.install_serializer(client=client)
134-
client._transport.serializers.default_serializer = cls()
134+
client.transport.serializers.default_serializer = cls()
135135

136136

137137
class LessCapableJsonSerializer(InstallSerializerMixin, JsonSerializer):

key-value/key-value-aio/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import subprocess
66
from collections.abc import Callable, Iterator
77
from contextlib import contextmanager
8-
from time import sleep
98

109
import pytest
1110
from docker import DockerClient
1211
from docker.models.containers import Container
12+
from key_value.shared.code_gen.sleep import sleep
1313

1414
logger = logging.getLogger(__name__)
1515

key-value/key-value-aio/tests/stores/elasticsearch/test_elasticsearch.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def test_put_put_two_indices(self, store: ElasticsearchStore, es_client: A
145145

146146
@pytest.mark.skipif(should_skip_docker_tests(), reason="Docker is not running")
147147
class TestElasticsearchStoreNativeMode(BaseTestElasticsearchStore):
148-
"""Test Elasticsearch store in native mode"""
148+
"""Test Elasticsearch store in native mode (i.e. it stores flattened objects)"""
149149

150150
@override
151151
@pytest.fixture
@@ -208,7 +208,7 @@ async def test_migration_from_legacy_mode(self, store: ElasticsearchStore, es_cl
208208

209209

210210
class TestElasticsearchStoreNonNativeMode(BaseTestElasticsearchStore):
211-
"""Test Elasticsearch store in non-native mode"""
211+
"""Test Elasticsearch store in non-native mode (i.e. it stores stringified JSON values)"""
212212

213213
@override
214214
@pytest.fixture
@@ -220,8 +220,6 @@ async def test_value_stored_as_json_string(self, store: ElasticsearchStore, es_c
220220
"""Verify values are stored as flattened objects, not JSON strings"""
221221
await store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
222222

223-
# Check raw Elasticsearch document using public sanitization methods
224-
# Note: We need to access these internal methods for testing the storage format
225223
index_name = store._sanitize_index_name(collection="test") # pyright: ignore[reportPrivateUsage]
226224
doc_id = store._sanitize_document_id(key="test_key") # pyright: ignore[reportPrivateUsage]
227225

@@ -250,7 +248,6 @@ async def test_value_stored_as_json_string(self, store: ElasticsearchStore, es_c
250248

251249
async def test_migration_from_native_mode(self, store: ElasticsearchStore, es_client: AsyncElasticsearch):
252250
"""Verify non-native mode can read native mode data"""
253-
# Manually insert a legacy document with JSON string value
254251
index_name = store._sanitize_index_name(collection="test") # pyright: ignore[reportPrivateUsage]
255252
doc_id = store._sanitize_document_id(key="legacy_key") # pyright: ignore[reportPrivateUsage]
256253

@@ -266,6 +263,5 @@ async def test_migration_from_native_mode(self, store: ElasticsearchStore, es_cl
266263

267264
await es_client.indices.refresh(index=index_name)
268265

269-
# Should be able to read it in native mode
270266
result = await store.get(collection="test", key="legacy_key")
271267
assert result == snapshot({"name": "Alice", "age": 30})

key-value/key-value-sync/src/key_value/sync/code_gen/stores/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def _put_managed_entries(
252252
created_at: datetime,
253253
expires_at: datetime | None,
254254
) -> None:
255+
255256
"""Store multiple managed entries by key in the specified collection.
256257
257258
Args:

key-value/key-value-sync/src/key_value/sync/code_gen/stores/elasticsearch/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ class InstallSerializerMixin:
123123

124124
@classmethod
125125
def install_serializer(cls, client: Elasticsearch) -> None:
126-
client._transport.serializers.serializers.update({cls.mimetype: cls(), cls.compatibility_mimetype: cls()})
126+
client.transport.serializers.serializers.update({cls.mimetype: cls(), cls.compatibility_mimetype: cls()})
127127

128128
@classmethod
129129
def install_default_serializer(cls, client: Elasticsearch) -> None:
130130
cls.install_serializer(client=client)
131-
client._transport.serializers.default_serializer = cls()
131+
client.transport.serializers.default_serializer = cls()
132132

133133

134134
class LessCapableJsonSerializer(InstallSerializerMixin, JsonSerializer):

key-value/key-value-sync/tests/code_gen/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import subprocess
99
from collections.abc import Callable, Iterator
1010
from contextlib import contextmanager
11-
from time import sleep
1211

1312
import pytest
1413
from docker import DockerClient
1514
from docker.models.containers import Container
15+
from key_value.shared.code_gen.sleep import sleep
1616

1717
logger = logging.getLogger(__name__)
1818

key-value/key-value-sync/tests/code_gen/stores/elasticsearch/test_elasticsearch.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_put_put_two_indices(self, store: ElasticsearchStore, es_client: Elastic
146146

147147
@pytest.mark.skipif(should_skip_docker_tests(), reason="Docker is not running")
148148
class TestElasticsearchStoreNativeMode(BaseTestElasticsearchStore):
149-
"""Test Elasticsearch store in native mode"""
149+
"""Test Elasticsearch store in native mode (i.e. it stores flattened objects)"""
150150

151151
@override
152152
@pytest.fixture
@@ -202,7 +202,7 @@ def test_migration_from_legacy_mode(self, store: ElasticsearchStore, es_client:
202202

203203

204204
class TestElasticsearchStoreNonNativeMode(BaseTestElasticsearchStore):
205-
"""Test Elasticsearch store in non-native mode"""
205+
"""Test Elasticsearch store in non-native mode (i.e. it stores stringified JSON values)"""
206206

207207
@override
208208
@pytest.fixture
@@ -214,8 +214,6 @@ def test_value_stored_as_json_string(self, store: ElasticsearchStore, es_client:
214214
"""Verify values are stored as flattened objects, not JSON strings"""
215215
store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
216216

217-
# Check raw Elasticsearch document using public sanitization methods
218-
# Note: We need to access these internal methods for testing the storage format
219217
index_name = store._sanitize_index_name(collection="test") # pyright: ignore[reportPrivateUsage]
220218
doc_id = store._sanitize_document_id(key="test_key") # pyright: ignore[reportPrivateUsage]
221219

@@ -244,7 +242,6 @@ def test_value_stored_as_json_string(self, store: ElasticsearchStore, es_client:
244242

245243
def test_migration_from_native_mode(self, store: ElasticsearchStore, es_client: Elasticsearch):
246244
"""Verify non-native mode can read native mode data"""
247-
# Manually insert a legacy document with JSON string value
248245
index_name = store._sanitize_index_name(collection="test") # pyright: ignore[reportPrivateUsage]
249246
doc_id = store._sanitize_document_id(key="legacy_key") # pyright: ignore[reportPrivateUsage]
250247

@@ -256,6 +253,5 @@ def test_migration_from_native_mode(self, store: ElasticsearchStore, es_client:
256253

257254
es_client.indices.refresh(index=index_name)
258255

259-
# Should be able to read it in native mode
260256
result = store.get(collection="test", key="legacy_key")
261257
assert result == snapshot({"name": "Alice", "age": 30})

0 commit comments

Comments
 (0)