2020sys .path .append (os .path .join (script_dir , ".." ))
2121import s3_express_getting_started
2222
23+ number_of_uploads = 10
2324
24- @pytest .mark .parametrize (
25- "error_code, stop_on_index" ,
26- [
25+ stop_on_index = [
2726 ("TESTERROR-stub_create_vpc" , 0 ),
2827 ("TESTERROR-stub_describe_route_tables" , 1 ),
2928 ("TESTERROR-stub_create_vpc_endpoint" , 2 ),
3029 ("TESTERROR-stub_create_stack" , 3 ),
3130 ("TESTERROR-stub_describe_stacks" , 4 ),
32- ],
31+ ("TESTERROR-stub_create_access_key_regular" , 5 ),
32+ ("TESTERROR-stub_create_access_key_directory" , 6 ),
33+ ("TESTERROR-stub_describe_availability_zones" , 7 ),
34+ ("TESTERROR-stub_create_bucket_directory" , 8 ),
35+ ("TESTERROR-stub_create_bucket_regular" , 9 ),
36+ ("TESTERROR-stub_put_object" , 10 ),
37+ ("TESTERROR-stub_create_session" , 11 ),
38+ ("TESTERROR-stub_copy_object" , 12 ),
39+ ]
40+
41+ for i in range (len (stop_on_index ), len (stop_on_index ) + number_of_uploads ):
42+ stop_on_index .append ((f"TESTERROR-stub_get_object_directory" , i ))
43+
44+ for i in range (len (stop_on_index ), len (stop_on_index ) + number_of_uploads ):
45+ stop_on_index .append ((f"TESTERROR-stub_get_object_regular" , i ))
46+
47+ @pytest .mark .parametrize (
48+ "error_code, stop_on_index" ,
49+ stop_on_index ,
3350)
3451def test_s3_express_scenario (
3552 make_stubber , stub_runner , error_code , stop_on_index , monkeypatch
@@ -67,8 +84,26 @@ def test_s3_express_scenario(
6784 {"OutputKey" : "ExpressUser" , "OutputValue" : express_user_name },
6885 ]
6986
87+ availability_zone_filter = [{"Name" : "region-name" , "Values" : [region ]}]
88+ availability_zone_ids = ["use1-az2" ]
89+
90+ bucket_name_prefix = "amzn-s3-demo-bucket"
91+ directory_bucket_name = f"{ bucket_name_prefix } -{ my_uuid } --{ availability_zone_ids [0 ]} --x-s3"
92+ regular_bucket_name = f"{ bucket_name_prefix } -regular-{ my_uuid } "
93+
94+ directory_bucket_configuration = { 'Bucket' : { 'Type' : 'Directory' ,
95+ 'DataRedundancy' : 'SingleAvailabilityZone' },
96+ 'Location' : { 'Name' : availability_zone_ids [0 ],
97+ 'Type' : 'AvailabilityZone' }
98+ }
99+
100+ object_name = "basic-text-object"
70101 inputs = [
71102 "y" ,
103+ bucket_name_prefix ,
104+ "1" ,
105+ "y" ,
106+ number_of_uploads
72107 ]
73108 monkeypatch .setattr ("builtins.input" , lambda x : inputs .pop (0 ))
74109
@@ -81,6 +116,20 @@ def test_s3_express_scenario(
81116 runner .add (ec2_stubber .stub_create_vpc_endpoint , vpc_id , route_table_id , service_name )
82117 runner .add (cloud_formation_stubber .stub_create_stack , stack_name , template , ["CAPABILITY_NAMED_IAM" ], stack_id )
83118 runner .add (cloud_formation_stubber .stub_describe_stacks , stack_name , "CREATE_COMPLETE" , outputs )
119+ runner .add (iam_stubber .stub_create_access_key , regular_user_name )
120+ runner .add (iam_stubber .stub_create_access_key , express_user_name )
121+ runner .add (ec2_stubber .stub_describe_availability_zones , availability_zone_ids , availability_zone_filter , availability_zone_ids )
122+ runner .add (s3_stubber .stub_create_bucket , directory_bucket_name , bucket_configuration = directory_bucket_configuration )
123+ runner .add (s3_stubber .stub_create_bucket , regular_bucket_name )
124+ runner .add (s3_stubber .stub_put_object , regular_bucket_name , object_name , "Look Ma, I'm a bucket!" )
125+ runner .add (s3_stubber .stub_create_session , directory_bucket_name )
126+ runner .add (s3_stubber .stub_copy_object , regular_bucket_name , object_name , directory_bucket_name , object_name )
127+
128+ for _ in range (number_of_uploads ):
129+ runner .add (s3_stubber .stub_get_object , directory_bucket_name , object_name )
130+
131+ for _ in range (number_of_uploads ):
132+ runner .add (s3_stubber .stub_get_object , regular_bucket_name , object_name )
84133
85134 def mock_wait (self , ** kwargs ):
86135 return
0 commit comments