-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
243 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
AWS_REGION_NAME="" | ||
AWS_ACCESS_KEY_ID="" | ||
AWS_SECRET_ACCESS_KEY="" | ||
AWS_HOST="" | ||
AWS_QUEUE_NAME="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#!/bin/bash | ||
VERBOSE=1 | ||
|
||
# Run only unit tests in CI | ||
test: | ||
poetry run nose2 --verbosity $(VERBOSE) $(target) | ||
poetry run nose2 -s aiosqs --verbosity $(VERBOSE) $(target) | ||
|
||
# Run E2E tests locally during development | ||
test_e2e: | ||
poetry run nose2 -s e2e --verbosity $(VERBOSE) $(target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> | ||
<Error> | ||
<Type>Sender</Type> | ||
<Code>InvalidClientTokenId</Code> | ||
<Message>key_id is invalid</Message> | ||
<Details/> | ||
</Error> | ||
<RequestId>4622a4ae-1166-48d6-bf50-2091ab4caafb</RequestId> | ||
</ErrorResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> | ||
<Error> | ||
<Type>Sender</Type> | ||
<Code>InvalidClientTokenId</Code> | ||
<Message>The security token included in the request is invalid.</Message> | ||
<Details/> | ||
</Error> | ||
<RequestId>d4b992fa-9b39-4176-9e11-864b040ebbf3</RequestId> | ||
</ErrorResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0"?> | ||
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> | ||
<Error> | ||
<Type>Sender</Type> | ||
<Code>SignatureDoesNotMatch</Code> | ||
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. | ||
|
||
The Canonical String for this request should have been | ||
'GET | ||
/ | ||
Action=SendMessage&DelaySeconds=0&MessageBody=message%20%20with%20a%20space&QueueUrl=https%3A%2F%2Fsqs.us-east-1.amazonaws.com%2F763215857860%2Fcontent-repository-processing-queue-prod&Version=2012-11-05 | ||
host:sqs.us-east-1.amazonaws.com | ||
x-amz-date:20231205T232537Z | ||
|
||
host;x-amz-date | ||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' | ||
|
||
The String-to-Sign should have been | ||
'AWS4-HMAC-SHA256 | ||
20231205T232537Z | ||
20231205/us-east-1/sqs/aws4_request | ||
4ea765b1b277df9a9b929ee3383f75060631e8f75fb38b9c8b8b05a84c009474' | ||
</Message> | ||
<Detail/> | ||
</Error> | ||
<RequestId>f679cf26-effe-5e59-81ca-92cf5c4c713b</RequestId> | ||
</ErrorResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import unittest | ||
import logging | ||
|
||
from dotenv import dotenv_values | ||
|
||
from aiosqs import SQSClient, SQSErrorResponse | ||
|
||
|
||
class E2ETestCase(unittest.IsolatedAsyncioTestCase): | ||
@classmethod | ||
def setUpClass(cls) -> None: | ||
config = dotenv_values(".env") | ||
cls.region_name = config["AWS_REGION_NAME"] | ||
cls.aws_access_key_id = config["AWS_ACCESS_KEY_ID"] | ||
cls.aws_secret_access_key = config["AWS_SECRET_ACCESS_KEY"] | ||
cls.host = config["AWS_HOST"] | ||
cls.queue_name = config["AWS_QUEUE_NAME"] | ||
|
||
async def asyncSetUp(self): | ||
await super().asyncSetUp() | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.CRITICAL) | ||
|
||
self.client = SQSClient( | ||
region_name=self.region_name, | ||
aws_access_key_id=self.aws_access_key_id, | ||
aws_secret_access_key=self.aws_secret_access_key, | ||
host=self.host, | ||
verify_ssl=False, | ||
logger=logger, | ||
) | ||
|
||
async def asyncTearDown(self): | ||
await self.client.close() | ||
|
||
async def test_get_queue_url(self): | ||
response = await self.client.get_queue_url(queue_name=self.queue_name) | ||
queue_url = response["QueueUrl"] | ||
self.assertTrue(queue_url.endswith(self.queue_name), msg=queue_url) | ||
|
||
async def test_call_unknown_queue_name(self): | ||
with self.assertRaises(SQSErrorResponse) as e: | ||
await self.client.get_queue_url(queue_name="ErrorDoesNotExistName") | ||
exception = e.exception | ||
self.assertEqual(exception.error.type, "Sender") | ||
self.assertEqual(exception.error.code, "AWS.SimpleQueueService.NonExistentQueue") | ||
self.assertEqual(exception.error.message, "The specified queue doesn't exist.") | ||
|
||
async def test_send_message_with_raw_text(self): | ||
response = await self.client.get_queue_url(queue_name=self.queue_name) | ||
queue_url = response["QueueUrl"] | ||
|
||
message_body = "a b c d" | ||
response = await self.client.send_message( | ||
queue_url=queue_url, | ||
message_body=message_body, | ||
) | ||
self.assertEqual(set(response.keys()), {"MessageId", "MD5OfMessageBody"}) | ||
|
||
response = await self.client.receive_message( | ||
queue_url=queue_url, | ||
max_number_of_messages=1, | ||
visibility_timeout=60, | ||
) | ||
self.assertTrue(len(response) > 0) | ||
|
||
message = response[0] | ||
receipt_handle = message["ReceiptHandle"] | ||
self.assertEqual(message["Body"], message_body) | ||
|
||
response = await self.client.delete_message( | ||
queue_url=queue_url, | ||
receipt_handle=receipt_handle, | ||
) | ||
self.assertIsNone(response) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ Source = "https://github.com/d3QUone/aiosqs" | |
|
||
[tool.poetry] | ||
name = "aiosqs" | ||
version = "0.1.0" | ||
version = "1.0.3" | ||
description = "Python asynchronous and lightweight SQS client." | ||
authors = ["Vladimir Kasatkin <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -60,6 +60,7 @@ freezegun = "1.2.2" | |
pre-commit = "2.17.0" | ||
packaging = "23.2" | ||
aioresponses = "0.7.6" | ||
python-dotenv = "1.0.0" | ||
|
||
[tool.black] | ||
line-length = 140 | ||
|
@@ -85,4 +86,5 @@ exclude = [ | |
"/MAINTAIN.md", | ||
"/Makefile", | ||
"/aiosqs/tests", | ||
"/e2e", | ||
] |