Skip to content

Commit df44aa4

Browse files
committed
Tests except for issues with cleanup
1 parent 2736d04 commit df44aa4

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

python/example_code/s3/s3_basics/test/test_s3_express_getting_started.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
for i in range(len(stop_on_index), len(stop_on_index) + number_of_uploads):
4545
stop_on_index.append((f"TESTERROR-stub_get_object_regular", i))
4646

47+
current_stop_on_index_length = len(stop_on_index)
48+
stop_on_index.extend([
49+
("TESTERROR-stub_put_object_other_object", current_stop_on_index_length),
50+
("TESTERROR-stub_put_object_other_object", current_stop_on_index_length + 1),
51+
("TESTERROR-stub_put_object_alt_object", current_stop_on_index_length + 2),
52+
("TESTERROR-stub_put_object_alt_object", current_stop_on_index_length + 3),
53+
("TESTERROR-stub_put_object_other_alt_object", current_stop_on_index_length + 4),
54+
("TESTERROR-stub_put_object_other_alt_object", current_stop_on_index_length + 5),
55+
("TESTERROR-stub_list_objects_directory", current_stop_on_index_length + 6),
56+
("TESTERROR-stub_list_objects_regular", current_stop_on_index_length + 7),
57+
("TESTERROR-stub_list_objects_directory", current_stop_on_index_length + 8),
58+
("TESTERROR-stub_delete_objects_directory", current_stop_on_index_length + 9),
59+
])
60+
4761
@pytest.mark.parametrize(
4862
"error_code, stop_on_index",
4963
stop_on_index,
@@ -98,12 +112,19 @@ def test_s3_express_scenario(
98112
}
99113

100114
object_name = "basic-text-object"
115+
other_object = f"other/{object_name}"
116+
alt_object = f"alt/{object_name}"
117+
other_alt_object = f"other/alt/{object_name}"
118+
119+
object_keys = [object_name, other_object, alt_object, other_alt_object]
120+
101121
inputs = [
102122
"y",
103123
bucket_name_prefix,
104124
"1",
105125
"y",
106-
number_of_uploads
126+
number_of_uploads,
127+
"y"
107128
]
108129
monkeypatch.setattr("builtins.input", lambda x: inputs.pop(0))
109130

@@ -131,6 +152,20 @@ def test_s3_express_scenario(
131152
for _ in range(number_of_uploads):
132153
runner.add(s3_stubber.stub_get_object, regular_bucket_name, object_name)
133154

155+
runner.add (s3_stubber.stub_put_object, regular_bucket_name, other_object, "")
156+
runner.add (s3_stubber.stub_put_object, directory_bucket_name, other_object, "")
157+
runner.add (s3_stubber.stub_put_object, regular_bucket_name, alt_object, "")
158+
runner.add (s3_stubber.stub_put_object, directory_bucket_name, alt_object, "")
159+
runner.add (s3_stubber.stub_put_object, regular_bucket_name, other_alt_object, "")
160+
runner.add (s3_stubber.stub_put_object, directory_bucket_name, other_alt_object, "")
161+
162+
runner.add(s3_stubber.stub_list_objects_v2, directory_bucket_name, object_keys)
163+
runner.add(s3_stubber.stub_list_objects_v2, regular_bucket_name, object_keys)
164+
165+
runner.add(s3_stubber.stub_list_objects_v2, directory_bucket_name, object_keys)
166+
runner.add(s3_stubber.stub_delete_objects, directory_bucket_name, object_keys)
167+
168+
134169
def mock_wait(self, **kwargs):
135170
return
136171

python/test_tools/s3_stubber.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,26 @@ def stub_list_objects(
325325
"list_objects", expected_params, response, error_code=error_code
326326
)
327327

328+
def stub_list_objects_v2(
329+
self,
330+
bucket_name,
331+
object_keys=None,
332+
prefix=None,
333+
delimiter=None,
334+
error_code=None,
335+
):
336+
if not object_keys:
337+
object_keys = []
338+
expected_params = {"Bucket": bucket_name}
339+
if prefix is not None:
340+
expected_params["Prefix"] = prefix
341+
if delimiter is not None:
342+
expected_params["Delimiter"] = delimiter
343+
response = {"Contents": [{"Key": key} for key in object_keys]}
344+
self._stub_bifurcator(
345+
"list_objects_v2", expected_params, response, error_code=error_code
346+
)
347+
328348
def stub_delete_objects(self, bucket_name, object_keys, error_code=None):
329349
expected_params = {
330350
"Bucket": bucket_name,

0 commit comments

Comments
 (0)