@@ -123,56 +123,91 @@ def test_write_to_release_id_file_broken_file_permissions(release_id_file):
123123
124124
125125def test_download_metadata_file (downloads_dir ):
126- s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
127- cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (GARDENLINUX_RELEASE , GARDENLINUX_COMMIT_SHORT ))
128- download_metadata_file (s3_artifacts ,
129- cname .cname ,
130- GARDENLINUX_RELEASE ,
131- GARDENLINUX_COMMIT_SHORT ,
132- S3_DOWNLOADS_DIR )
133- assert (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
134-
135-
136- def test_download_metadata_file_no_such_release (downloads_dir ):
137- s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
138- release = "0000.0"
139- commit = GARDENLINUX_COMMIT_SHORT
140- cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
141- with pytest .raises (IndexError ):
126+ with mock_aws ():
127+ s3 = boto3 .resource ("s3" , region_name = "eu-central-1" )
128+ s3 .create_bucket (Bucket = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME ,
129+ CreateBucketConfiguration = {
130+ 'LocationConstraint' : 'eu-central-1' })
131+ bucket = s3 .Bucket (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
132+ bucket .upload_file (S3_ARTIFACTS / "aws-gardener_prod-amd64.s3_metadata.yaml" ,
133+ f"meta/singles/aws-gardener_prod-amd64-{ GARDENLINUX_RELEASE } -{ GARDENLINUX_COMMIT } " )
134+
135+ s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
136+ cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (GARDENLINUX_RELEASE , GARDENLINUX_COMMIT_SHORT ))
142137 download_metadata_file (s3_artifacts ,
143138 cname .cname ,
144- release ,
145- commit ,
139+ GARDENLINUX_RELEASE ,
140+ GARDENLINUX_COMMIT_SHORT ,
146141 S3_DOWNLOADS_DIR )
147- assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
142+ assert (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
143+
144+
145+ def test_download_metadata_file_no_such_release (downloads_dir ):
146+ with mock_aws ():
147+ s3 = boto3 .resource ("s3" , region_name = "eu-central-1" )
148+ s3 .create_bucket (Bucket = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME ,
149+ CreateBucketConfiguration = {
150+ 'LocationConstraint' : 'eu-central-1' })
151+ bucket = s3 .Bucket (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
152+ bucket .upload_file (S3_ARTIFACTS / "aws-gardener_prod-amd64.s3_metadata.yaml" ,
153+ f"meta/singles/aws-gardener_prod-amd64-{ GARDENLINUX_RELEASE } -{ GARDENLINUX_COMMIT } " )
154+ s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
155+ release = "0000.0"
156+ commit = GARDENLINUX_COMMIT_SHORT
157+ cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
158+ with pytest .raises (IndexError ):
159+ download_metadata_file (s3_artifacts ,
160+ cname .cname ,
161+ release ,
162+ commit ,
163+ S3_DOWNLOADS_DIR )
164+ assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
148165
149166
150167def test_download_metadata_file_no_such_commit (downloads_dir ):
151- s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
152- release = GARDENLINUX_RELEASE
153- commit = "deadbeef"
154- cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
155- with pytest .raises (IndexError ):
156- download_metadata_file (s3_artifacts ,
157- cname .cname ,
158- release ,
159- commit ,
160- S3_DOWNLOADS_DIR )
161- assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
168+ with mock_aws ():
169+ s3 = boto3 .resource ("s3" , region_name = "eu-central-1" )
170+ s3 .create_bucket (Bucket = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME ,
171+ CreateBucketConfiguration = {
172+ 'LocationConstraint' : 'eu-central-1' })
173+ bucket = s3 .Bucket (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
174+ bucket .upload_file (S3_ARTIFACTS / "aws-gardener_prod-amd64.s3_metadata.yaml" ,
175+ f"meta/singles/aws-gardener_prod-amd64-{ GARDENLINUX_RELEASE } -{ GARDENLINUX_COMMIT } " )
176+
177+ s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
178+ release = GARDENLINUX_RELEASE
179+ commit = "deadbeef"
180+ cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
181+ with pytest .raises (IndexError ):
182+ download_metadata_file (s3_artifacts ,
183+ cname .cname ,
184+ release ,
185+ commit ,
186+ S3_DOWNLOADS_DIR )
187+ assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
162188
163189
164190def test_download_metadata_file_no_such_release_and_commit (downloads_dir ):
165- s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
166- release = "0000.0"
167- commit = "deadbeef"
168- cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
169- with pytest .raises (IndexError ):
170- download_metadata_file (s3_artifacts ,
171- cname .cname ,
172- release ,
173- commit ,
174- S3_DOWNLOADS_DIR )
175- assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
191+ with mock_aws ():
192+ s3 = boto3 .resource ("s3" , region_name = "eu-central-1" )
193+ s3 .create_bucket (Bucket = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME ,
194+ CreateBucketConfiguration = {
195+ 'LocationConstraint' : 'eu-central-1' })
196+ bucket = s3 .Bucket (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
197+ bucket .upload_file (S3_ARTIFACTS / "aws-gardener_prod-amd64.s3_metadata.yaml" ,
198+ f"meta/singles/aws-gardener_prod-amd64-{ GARDENLINUX_RELEASE } -{ GARDENLINUX_COMMIT } " )
199+
200+ s3_artifacts = S3Artifacts (GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME )
201+ release = "0000.0"
202+ commit = "deadbeef"
203+ cname = CName ("aws-gardener_prod" , "amd64" , "{0}-{1}" .format (release , commit ))
204+ with pytest .raises (IndexError ):
205+ download_metadata_file (s3_artifacts ,
206+ cname .cname ,
207+ release ,
208+ commit ,
209+ S3_DOWNLOADS_DIR )
210+ assert not (S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml" ).exists ()
176211
177212
178213def test_release_notes_changes_section_empty_packagelist ():
0 commit comments