4
4
import uuid
5
5
6
6
import boto3
7
+ import pytest
7
8
import requests
8
9
9
10
if typing .TYPE_CHECKING :
10
11
from mypy_boto3_s3 import S3Client
11
12
from mypy_boto3_ssm import SSMClient
13
+ from mypy_boto3_lambda import LambdaClient
12
14
13
15
os .environ ["AWS_DEFAULT_REGION" ] = "us-east-1"
14
16
os .environ ["AWS_ACCESS_KEY_ID" ] = "test"
20
22
ssm : "SSMClient" = boto3 .client (
21
23
"ssm" , endpoint_url = "http://localhost.localstack.cloud:4566"
22
24
)
25
+ awslambda : "LambdaClient" = boto3 .client (
26
+ "lambda" , endpoint_url = "http://localhost.localstack.cloud:4566"
27
+ )
28
+
29
+
30
+ @pytest .fixture (autouse = True )
31
+ def _wait_for_lambdas ():
32
+ # makes sure that the lambdas are available before running integration tests
33
+ awslambda .get_waiter ("function_active" ).wait (FunctionName = "presign" )
34
+ awslambda .get_waiter ("function_active" ).wait (FunctionName = "resize" )
35
+ awslambda .get_waiter ("function_active" ).wait (FunctionName = "list" )
23
36
24
37
25
38
def test_s3_resize_integration ():
@@ -34,14 +47,8 @@ def test_s3_resize_integration():
34
47
35
48
s3 .upload_file (file , Bucket = source_bucket , Key = key )
36
49
37
- # try for 15 seconds to wait for the resized image
38
- for i in range (15 ):
39
- try :
40
- s3 .head_object (Bucket = target_bucket , Key = key )
41
- break
42
- except :
43
- pass
44
- time .sleep (1 )
50
+ # wait for the resized image to appear
51
+ s3 .get_waiter ("object_exists" ).wait (Bucket = target_bucket , Key = key )
45
52
46
53
s3 .head_object (Bucket = target_bucket , Key = key )
47
54
s3 .download_file (
0 commit comments