From 565d2bb251eba754a6c0a826520d976dee597194 Mon Sep 17 00:00:00 2001 From: LMaterne <54711385+LMaterne@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:54:47 +0100 Subject: [PATCH] Add StreamSummaries to the respose of kinesis.list_streams (#7490) --- moto/kinesis/responses.py | 9 ++++++++- tests/test_kinesis/test_kinesis.py | 20 ++++++++++++++++++++ tests/test_kinesis/test_server.py | 6 +++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/moto/kinesis/responses.py b/moto/kinesis/responses.py index 994583437..ba873a7ff 100644 --- a/moto/kinesis/responses.py +++ b/moto/kinesis/responses.py @@ -53,7 +53,14 @@ class KinesisResponse(BaseResponse): has_more_streams = True return json.dumps( - {"HasMoreStreams": has_more_streams, "StreamNames": streams_resp} + { + "HasMoreStreams": has_more_streams, + "StreamNames": streams_resp, + "StreamSummaries": [ + stream.to_json_summary()["StreamDescriptionSummary"] + for stream in streams + ], + } ) def delete_stream(self) -> str: diff --git a/tests/test_kinesis/test_kinesis.py b/tests/test_kinesis/test_kinesis.py index 954e2baad..b4e4755cf 100644 --- a/tests/test_kinesis/test_kinesis.py +++ b/tests/test_kinesis/test_kinesis.py @@ -137,6 +137,26 @@ def test_describe_stream_summary(): assert stream["StreamName"] == stream_name +@mock_aws +def test_list_streams_stream_discription(): + conn = boto3.client("kinesis", region_name="us-west-2") + + for i in range(3): + conn.create_stream(StreamName=f"stream{i}", ShardCount=i+1) + + resp = conn.list_streams() + assert len(resp["StreamSummaries"]) == 3 + for i, stream in enumerate(resp["StreamSummaries"]): + stream_name = f"stream{i}" + assert stream["StreamName"] == stream_name + assert ( + stream["StreamARN"] + == f"arn:aws:kinesis:us-west-2:{ACCOUNT_ID}:stream/{stream_name}" + ) + assert stream["StreamStatus"] == "ACTIVE" + assert stream.get("StreamCreationTimestamp") + + @mock_aws def test_basic_shard_iterator(): client = boto3.client("kinesis", region_name="us-west-1") diff --git a/tests/test_kinesis/test_server.py b/tests/test_kinesis/test_server.py index 8eb20016e..1ac1beb7d 100644 --- a/tests/test_kinesis/test_server.py +++ b/tests/test_kinesis/test_server.py @@ -12,4 +12,8 @@ def test_list_streams(): res = test_client.get("/?Action=ListStreams") json_data = json.loads(res.data.decode("utf-8")) - assert json_data == {"HasMoreStreams": False, "StreamNames": []} + assert json_data == { + "HasMoreStreams": False, + "StreamNames": [], + "StreamSummaries": [] + }