Skip to content

Commit ca05f9b

Browse files
committed
Small fixups
1 parent 09892cb commit ca05f9b

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

tests/integration/src/handlers/CreateJpegFromRaw/__init__.py

Whitespace-only changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'''Test CreateJpgFromRaw'''
2+
3+
import json
4+
import os
5+
6+
import boto3
7+
8+
import pytest
9+
from aws_lambda_powertools.utilities.data_classes import S3Event
10+
from mypy_boto3_cloudformation import CloudFormationClient
11+
from mypy_boto3_lambda import LambdaClient
12+
from mypy_boto3_events import EventsClient
13+
14+
STACK_NAME = os.environ.get('STACK_NAME')
15+
FUNCTION_LOGICAL_ID = 'CreateJpegFromRaw'
16+
EVENT_BUS_LOGICAL_ID = 'EventBus'
17+
IMAGE_BUCKET_PATH = os.environ.get('TEST_PHOTO_IMAGE_BUCKET_PATH', 'DUMMY_BUCKET').strip('/').split('/', 1)
18+
BUCKET_NAME = IMAGE_BUCKET_PATH[0]
19+
BUCKET_PATH = IMAGE_BUCKET_PATH[1].strip('/') if len(IMAGE_BUCKET_PATH) > 1 else ''
20+
21+
DATA_DIR = './data'
22+
EVENT_DIR = os.path.join(DATA_DIR, 'events')
23+
24+
## AWS
25+
@pytest.fixture()
26+
def session():
27+
'''Return a boto3 session'''
28+
return boto3.Session()
29+
30+
@pytest.fixture()
31+
def cfn_client(session) -> CloudFormationClient:
32+
'''Return a CFN client'''
33+
return session.client('cloudformation')
34+
35+
@pytest.fixture()
36+
def lambda_client(session) -> LambdaClient:
37+
'''Return a Lambda client'''
38+
return session.client('lambda')
39+
40+
@pytest.fixture()
41+
def lambda_function_name(cfn_client) -> str:
42+
'''Return the Lambda function name'''
43+
function_info = cfn_client.describe_stack_resource(
44+
StackName=STACK_NAME,
45+
LogicalResourceId=FUNCTION_LOGICAL_ID
46+
)
47+
return function_info['StackResourceDetail']['PhysicalResourceId']
48+
49+
@pytest.fixture()
50+
def events_client(session) -> EventsClient:
51+
'''Return an SNS client'''
52+
return session.client('sns')
53+
54+
@pytest.fixture()
55+
def eventbus_name(cfn_client) -> str:
56+
'''Return the EventBus name'''
57+
eventbus_name = cfn_client.describe_stack_resource(
58+
StackName=STACK_NAME,
59+
LogicalResourceId=EVENT_BUS_LOGICAL_ID
60+
)
61+
return eventbus_name['StackResourceDetail']['PhysicalResourceId']
62+
63+
64+
### Events

tests/integration/src/handlers/IngestS3Event/test_function.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
DATA_DIR = './data'
2222
EVENT_DIR = os.path.join(DATA_DIR, 'events')
23-
IMAGE_DIR = os.path.join(DATA_DIR, 'images')
24-
MODEL_DIR = os.path.join(DATA_DIR, 'models')
2523

2624
## AWS
2725
@pytest.fixture()
@@ -107,6 +105,7 @@ def s3_put_event(generic_s3_put_notification, sns_topic_arn, request) -> S3Event
107105
return s3_notification_event
108106

109107

108+
### Tests
110109
def test_invoke_handler_s3_put(generic_sns_s3_put_event, generic_s3_put_notification, lambda_client, lambda_function_name):
111110
'''Test invoking handler with a PUT event'''
112111
resp = lambda_client.invoke(

0 commit comments

Comments
 (0)