Fixed error when returning empty bucket, closes #76

pull/84/head
Simon Willison 2022-08-12 10:22:08 -07:00
rodzic 5a9814d396
commit 30e07d3e68
2 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -1169,7 +1169,7 @@ def stream_indented_json(iterator, indent=2):
def paginate(service, method, list_key, **kwargs):
paginator = service.get_paginator(method)
for response in paginator.paginate(**kwargs):
yield from response[list_key]
yield from response.get(list_key) or []
def fix_json(row):

Wyświetl plik

@ -997,6 +997,15 @@ def test_list_bucket(stub_s3, options, expected):
assert result.output == expected
def test_list_bucket_empty(stub_s3):
stub_s3.add_response("list_objects_v2", {})
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(cli, ["list-bucket", "test-bucket"])
assert result.exit_code == 0
assert result.output == "[]\n"
@pytest.fixture
def stub_iam_for_list_roles(stub_iam):
stub_iam.add_response(