Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test_integ/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("Integration Test Logger")
Empty file added test_integ/fixtures/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions test_integ/fixtures/objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import boto3
import pytest
import uuid

@pytest.fixture
def default_message_size_threshold():
return 262144

@pytest.fixture
def small_message_body():
return "small message body"


@pytest.fixture
def small_message_attribute(small_message_body):
return {
'Small_Message_Attribute': {
'StringValue': small_message_body,
'DataType': 'String'
}
}

@pytest.fixture
def custom_s3_key_attribute():
return {
'S3Key': {
'StringValue': str(uuid.uuid4()),
'DataType': 'String'
}
}


@pytest.fixture
def large_message_body(small_message_body, default_message_size_threshold):
return "x" * ( default_message_size_threshold + 1 )

@pytest.fixture
def large_message_attribute(large_message_body):
return {
'Large_Message_Attribute': {
'StringValue': 'Test',
'DataType': 'String'
}
}
19 changes: 19 additions & 0 deletions test_integ/fixtures/session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import boto3
import pytest
from sns_extended_client.session import SNSExtendedClientSession

@pytest.fixture()
def region_name() -> str:
region_name = 'us-east-1'
return region_name

@pytest.fixture()
def session(region_name) -> boto3.Session:

setattr(boto3.session, "Session", SNSExtendedClientSession)
# Now take care of the reference in the boto3.__init__ module since the object is being imported there too
setattr(boto3, "Session", SNSExtendedClientSession)

# return boto3.session.Session()
print("This session is fetched")
return boto3.Session(region_name=region_name)
61 changes: 61 additions & 0 deletions test_integ/fixtures/sns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import boto3
from sns_extended_client import SNSExtendedClientSession
import pytest
import random

@pytest.fixture()
def sns_extended_client(session):
sns_client = session.client("sns",region_name='us-east-1')
sns_client.large_payload_support = f'integration-test-bucket-{random.randint(0, 10000)}'
return sns_client

@pytest.fixture()
def sqs_client(session):
return session.client("sqs")

@pytest.fixture()
def queue_name():
return f"IntegrationTestQueue{random.randint(0,10000)}"

@pytest.fixture()
def topic_name():
return f"IntegrationTestTopic{random.randint(0,10000)}"

@pytest.fixture()
def queue(sqs_client, queue_name):
queue_object = sqs_client.create_queue(QueueName=queue_name)

yield queue_object

sqs_client.purge_queue(
QueueUrl=queue_object['QueueUrl']
)

sqs_client.delete_queue(
QueueUrl=queue_object['QueueUrl']
)

@pytest.fixture()
def topic(sns_extended_client, topic_name):
topic_arn = sns_extended_client.create_topic(Name=topic_name).get("TopicArn")

yield topic_arn

sns_extended_client.delete_topic(
TopicArn=topic_arn
)

@pytest.fixture()
def sns_extended_client_with_s3(sns_extended_client):

client_sns = sns_extended_client

client_sns.s3_client.create_bucket(
Bucket=client_sns.large_payload_support
)

yield client_sns

client_sns.s3_client.delete_bucket(
Bucket=client_sns.large_payload_support,
)
Loading