-
Notifications
You must be signed in to change notification settings - Fork 1
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
8 changed files
with
72 additions
and
105 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,17 @@ | ||
import unittest | ||
|
||
from aiosqs.parser import parse_xml_result_response | ||
from aiosqs.tests.fixtures import load_fixture | ||
|
||
|
||
class ActionTestCase(unittest.TestCase): | ||
maxDiff = None | ||
action: str = None | ||
|
||
def parseXMLResponse(self, fixture_name: str): | ||
self.assertIsNotNone(self.action) | ||
res = parse_xml_result_response( | ||
action=self.action, | ||
body=load_fixture(fixture_name), | ||
) | ||
return res |
File renamed without changes.
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,15 +1,25 @@ | ||
import unittest | ||
from aiosqs.exceptions import SQSErrorResponse | ||
from aiosqs.tests.cases import ActionTestCase | ||
|
||
from aiosqs.parser import parse_xml_result_response | ||
from aiosqs.tests.utils import load_fixture | ||
|
||
|
||
class DeleteMessageTestCase(unittest.TestCase): | ||
class DeleteMessageTestCase(ActionTestCase): | ||
action = "DeleteMessage" | ||
|
||
def test_delete_message_ok(self): | ||
res = parse_xml_result_response( | ||
action=self.action, | ||
body=load_fixture("delete_message.xml"), | ||
) | ||
res = self.parseXMLResponse("delete_message.xml") | ||
self.assertIsNone(res) | ||
|
||
def test_delete_message_error(self): | ||
with self.assertRaises(SQSErrorResponse) as e: | ||
self.parseXMLResponse("error.xml") | ||
exception = e.exception | ||
self.assertEqual(exception.request_id, "42d59b56-7407-4c4a-be0f-4c88daeea257") | ||
self.assertEqual(exception.error.type, "Sender") | ||
self.assertEqual(exception.error.code, "InvalidParameterValue") | ||
self.assertEqual( | ||
exception.error.message, | ||
( | ||
"Value (quename_nonalpha) for parameter QueueName is invalid.\n " | ||
"Must be an alphanumeric String of 1 to 80 in length." | ||
), | ||
) |
This file was deleted.
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
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,21 +1,24 @@ | ||
import unittest | ||
from aiosqs.exceptions import SQSErrorResponse | ||
from aiosqs.tests.cases import ActionTestCase | ||
|
||
from aiosqs.parser import parse_xml_result_response | ||
from aiosqs.tests.utils import load_fixture | ||
|
||
|
||
class SendMessageTestCase(unittest.TestCase): | ||
class SendMessageTestCase(ActionTestCase): | ||
action = "SendMessage" | ||
|
||
def test_send_message_ok(self): | ||
res = parse_xml_result_response( | ||
action=self.action, | ||
body=load_fixture("send_message.xml"), | ||
) | ||
res = self.parseXMLResponse("send_message.xml") | ||
self.assertEqual( | ||
res, | ||
{ | ||
"MessageId": "acdf9b7f-a639-4a5b-9557-b4de52a56d01", | ||
"MD5OfMessageBody": "a88e5d79dc2948e662b90dc2857ba05c", | ||
}, | ||
) | ||
|
||
def test_signature_does_not_match(self): | ||
with self.assertRaises(SQSErrorResponse) as e: | ||
self.parseXMLResponse("error_signature.xml") | ||
exception = e.exception | ||
self.assertEqual(exception.request_id, "f679cf26-effe-5e59-81ca-92cf5c4c713b") | ||
self.assertEqual(exception.error.type, "Sender") | ||
self.assertEqual(exception.error.code, "SignatureDoesNotMatch") |