diff --git a/awsimple/__version__.py b/awsimple/__version__.py index 33a5a69..db2d7f4 100644 --- a/awsimple/__version__.py +++ b/awsimple/__version__.py @@ -1,7 +1,7 @@ __application_name__ = "awsimple" __title__ = __application_name__ __author__ = "abel" -__version__ = "4.0.0" +__version__ = "4.1.0" __author_email__ = "j@abel.co" __url__ = "https://github.com/jamesabel/awsimple" __download_url__ = "https://github.com/jamesabel/awsimple" diff --git a/awsimple/pubsub.py b/awsimple/pubsub.py index ce3d21f..5fc0016 100644 --- a/awsimple/pubsub.py +++ b/awsimple/pubsub.py @@ -140,8 +140,8 @@ def __init__( :param node_name: Node name (SQS queue name suffix). Defaults to a combination of computer name and username, but can be passed in for customization and/or testing. :param sub_callback: Optional thread and process safe callback function to be called when a new message is received. The function should accept a single argument, which will be the message as a dictionary. """ - self.channel = channel - self.node_name = node_name # e.g., computer name + self.channel = channel.lower() # when subscribing SQS queues to SNS topics, the names must all be lowercase (bizarre AWS "gotcha") + self.node_name = node_name.lower() # e.g., computer name or user and computer name self.sub_callback = sub_callback self.profile_name = profile_name diff --git a/requirements-dev.txt b/requirements-dev.txt index 00e9dc3..fe1bbdc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ # awsimple requirements hashy boto3 -typeguard<3 +typeguard dictim appdirs tobool diff --git a/setup.py b/setup.py index 8365e70..85c5b3a 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ keywords=["aws", "cloud", "storage", "database", "dynamodb", "s3"], packages=[__title__], package_data={__title__: [readme_file_path, "py.typed"]}, - install_requires=["boto3", "typeguard<3", "hashy>=0.1.1", "dictim", "appdirs", "tobool", "urllib3", "python-dateutil", "yasf"], + install_requires=["boto3", "typeguard", "hashy>=0.1.1", "dictim", "appdirs", "tobool", "urllib3", "python-dateutil", "yasf"], project_urls={"Documentation": "https://awsimple.readthedocs.io/"}, classifiers=[], python_requires=">3.10", diff --git a/test_awsimple/test_pubsub/test_pubsub_get_messages.py b/test_awsimple/test_pubsub/test_pubsub_get_messages.py index fb720d5..0bca9ee 100644 --- a/test_awsimple/test_pubsub/test_pubsub_get_messages.py +++ b/test_awsimple/test_pubsub/test_pubsub_get_messages.py @@ -1,6 +1,6 @@ import time -from awsimple import PubSub, is_mock +from awsimple import PubSub def test_pubsub_get_messages(): diff --git a/test_awsimple/test_pubsub/test_pubsub_mixed_case.py b/test_awsimple/test_pubsub/test_pubsub_mixed_case.py new file mode 100644 index 0000000..9ecf58b --- /dev/null +++ b/test_awsimple/test_pubsub/test_pubsub_mixed_case.py @@ -0,0 +1,29 @@ +import time + +from awsimple import PubSub + + +def test_pubsub_mixed_case(): + + test_channel = "MyTestChannel" # gets converted to lowercase for SNS topic and SQS queue + node_name = "MyNodeName" # gets converted to lowercase for SNS topic and SQS queue + sent_message = {"MyNumber": 1, "MyBoolean": True, "MyFloat": 2.0 / 3.0} + + pubsub = PubSub(test_channel, node_name) + pubsub.start() + + pubsub.publish(sent_message) + + received_message = None + count = 0 + while count < 600: + if len(messages := pubsub.get_messages()) > 0: + received_message = messages[0] + break + time.sleep(0.1) + + pubsub.terminate() + pubsub.join(60) + assert not pubsub.is_alive() + + assert received_message == sent_message diff --git a/test_awsimple/test_sns_publish.py b/test_awsimple/test_sns_publish.py index 426fbcb..dc1d99b 100644 --- a/test_awsimple/test_sns_publish.py +++ b/test_awsimple/test_sns_publish.py @@ -1,6 +1,4 @@ -import json - -from awsimple import SNSAccess, SQSPollAccess, is_mock +from awsimple import SNSAccess, SQSPollAccess from test_awsimple import test_awsimple_str, drain @@ -19,13 +17,7 @@ def test_sns_publish(): message_string = "This is a test for awsimple." subject_string = "awsimple test" - # doesn't work with moto :( - if not is_mock(): - message_id = sns_access.publish(message_string, subject_string) - print(f"{message_id=}") - assert message_id is not None and len(message_id) > 0 - - message = json.loads(sqs_access.receive_message().message) - returned_message_string = message["Message"] - print(f"{returned_message_string=}") - assert returned_message_string == message_string + + message_id = sns_access.publish(message_string, subject_string) + print(f"{message_id=}") + assert message_id is not None and len(message_id) > 0