8000 Add test for blob payload handling using HTTP client · localstack/localstack@e380b77 · GitHub
[go: up one dir, main page]

Skip to content < 65F1 script crossorigin="anonymous" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_document-metadata_document-metadata_ts-ui_packages_hydro-analytics_hydro-analytic-f29230-07417997172c.js" defer="defer">

Commit e380b77

Browse files
committed
Add test for blob payload handling using HTTP client
1 parent 71e1cca commit e380b77

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/aws/services/kinesis/test_kinesis.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,48 @@ def test_subscribe_to_shard_with_at_timestamp_cbor(
670670
)
671671
assert "ShardIterator" in shard_iterator_response_data
672672

673+
@markers.aws.validated
674+
def test_cbor_blob_handling(
675+
self,
676+
kinesis_create_stream,
677+
wait_for_stream_ready,
678+
aws_client,
679+
kinesis_http_client,
680+
):
681+
# create stream
682+
stream_name = kinesis_create_stream(ShardCount=1)
683+
wait_for_stream_ready(stream_name)
684+
685+
test_data = f"hello world {short_uid()}"
686+
687+
# put a record on to the stream
688+
kinesis_http_client.post(
689+
operation="PutRecord",
690+
payload={
691+
"Data": test_data.encode("utf-8"),
692+
"PartitionKey": f"key-{short_uid()}",
693+
"StreamName": stream_name,
694+
},
695+
)
696+
697+
# don't need to get shard iterator manually, so use the SDK
698+
shard_iterator: str | None = get_shard_iterator(stream_name, aws_client.kinesis)
699+
assert shard_iterator is not None
700+
701+
def _get_record():
702+
# send get records request via the http client
703+
get_records_response = kinesis_http_client.post(
704+
operation="GetRecords",
705+
payload={
706+
"ShardIterator": shard_iterator,
707+
},
708+
)
709+
assert len(get_records_response["Records"]) == 1
710+
return get_records_response["Records"][0]
711+
712+
record = retry(_get_record, sleep=1, retries=5)
713+
assert record["Data"].decode("utf-8") == test_data
714+
673715

674716
class TestKinesisPythonClient:
675717
@markers.skip_offline

tests/aws/services/kinesis/test_kinesis.validation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"tests/aws/services/kinesis/test_kinesis.py::TestKinesis::test_add_tags_to_stream": {
33
"last_validated_date": "2022-08-25T06:56:43+00:00"
44
},
5+
"tests/aws/services/kinesis/test_kinesis.py::TestKinesis::test_cbor_blob_handling": {
6+
"last_validated_date": "2024-07-17T20:09:34+00:00"
7+
},
58
"tests/aws/services/kinesis/test_kinesis.py::TestKinesis::test_create_stream_without_shard_count": {
69
"last_validated_date": "2022-08-26T07:30:59+00:00"
710
},

0 commit comments

Comments
 (0)
0