Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exclude = ["src/momento/internal/codegen.py"]
[tool.poetry.dependencies]
python = "^3.10"

momento-wire-types = "^0.135.0"
momento-wire-types = "^0.139.0"
# momento-wire-types 0.135's generated stubs refuse to import on grpcio < 1.83.1
grpcio = "^1.83.1"
# note if you bump this presigned url test need be updated
Expand Down
7 changes: 5 additions & 2 deletions src/momento/responses/control/cache/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ class ListCachesResponse(ControlResponse):

@dataclass
class CacheInfo:
"""Contains a Momento cache's name."""
"""Contains a Momento cache's name and id."""

name: str
"""Holds the name of the cache."""

id: str = ""
"""Holds the id of the cache. Empty if the server does not report one."""


class ListCaches(ABC):
"""Groups all `ListCachesResponse` derived types under a common namespace."""
Expand All @@ -66,7 +69,7 @@ def from_grpc_response(grpc_list_cache_response: ctrl_pb._ListCachesResponse) ->
Args:
grpc_list_cache_response: Protobuf based response returned by Scs.
"""
caches = [CacheInfo(cache.cache_name) for cache in grpc_list_cache_response.cache] # type: ignore[misc]
caches = [CacheInfo(cache.cache_name, cache.cache_id) for cache in grpc_list_cache_response.cache] # type: ignore[misc]
return ListCaches.Success(caches=caches)

class Error(ListCachesResponse, ErrorResponseMixin):
Expand Down
18 changes: 18 additions & 0 deletions tests/momento/responses/test_list_caches_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from __future__ import annotations

from momento.responses import ListCaches
from momento.responses.control.cache.list import CacheInfo
from momento_wire_types import controlclient_pb2 as ctrl_pb


def test_list_caches_success_maps_cache_name_and_id() -> None:
grpc_response = ctrl_pb._ListCachesResponse(
cache=[
ctrl_pb._Cache(cache_name="with-id", cache_id="0f1e2d3c"),
ctrl_pb._Cache(cache_name="without-id"),
]
)

response = ListCaches.Success.from_grpc_response(grpc_response)

assert response.caches == [CacheInfo(name="with-id", id="0f1e2d3c"), CacheInfo(name="without-id", id="")]
Loading