Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of failures is left to the next commit.
This commit is contained in:
parent
47dbad291e
commit
77dc60ea97
146 changed files with 1172 additions and 1277 deletions
1
tests/test_sqs/__init__.py
Normal file
1
tests/test_sqs/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# This file is intentionally left blank.
|
||||
|
|
@ -11,14 +11,13 @@ import boto3
|
|||
import botocore.exceptions
|
||||
import six
|
||||
import sure # noqa
|
||||
import tests.backport_assert_raises # noqa
|
||||
from boto.exception import SQSError
|
||||
from boto.sqs.message import Message, RawMessage
|
||||
from botocore.exceptions import ClientError
|
||||
from freezegun import freeze_time
|
||||
from moto import mock_sqs, mock_sqs_deprecated, mock_lambda, mock_logs, settings
|
||||
from nose import SkipTest
|
||||
from nose.tools import assert_raises
|
||||
from unittest import SkipTest
|
||||
import pytest
|
||||
from tests.helpers import requires_boto_gte
|
||||
from tests.test_awslambda.test_lambda import get_test_zip_file1, get_role_name
|
||||
from moto.core import ACCOUNT_ID
|
||||
|
|
@ -220,7 +219,7 @@ def test_get_queue_url_errors():
|
|||
@mock_sqs
|
||||
def test_get_nonexistent_queue():
|
||||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
with assert_raises(ClientError) as err:
|
||||
with pytest.raises(ClientError) as err:
|
||||
sqs.get_queue_by_name(QueueName="non-existing-queue")
|
||||
ex = err.exception
|
||||
ex.operation_name.should.equal("GetQueueUrl")
|
||||
|
|
@ -229,7 +228,7 @@ def test_get_nonexistent_queue():
|
|||
"The specified queue non-existing-queue does not exist for this wsdl version."
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as err:
|
||||
with pytest.raises(ClientError) as err:
|
||||
sqs.Queue("http://whatever-incorrect-queue-address").load()
|
||||
ex = err.exception
|
||||
ex.operation_name.should.equal("GetQueueAttributes")
|
||||
|
|
@ -368,7 +367,7 @@ def test_message_with_attributes_invalid_datatype():
|
|||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
queue = sqs.create_queue(QueueName="blah")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
queue.send_message(
|
||||
MessageBody="derp",
|
||||
MessageAttributes={
|
||||
|
|
@ -491,7 +490,7 @@ def test_delete_queue():
|
|||
queue.delete()
|
||||
conn.list_queues().get("QueueUrls").should.equal(None)
|
||||
|
||||
with assert_raises(botocore.exceptions.ClientError):
|
||||
with pytest.raises(botocore.exceptions.ClientError):
|
||||
queue.delete()
|
||||
|
||||
|
||||
|
|
@ -758,10 +757,10 @@ def test_max_number_of_messages_invalid_param():
|
|||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
queue = sqs.create_queue(QueueName="test-queue")
|
||||
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
queue.receive_messages(MaxNumberOfMessages=11)
|
||||
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
queue.receive_messages(MaxNumberOfMessages=0)
|
||||
|
||||
# no error but also no messages returned
|
||||
|
|
@ -773,10 +772,10 @@ def test_wait_time_seconds_invalid_param():
|
|||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
queue = sqs.create_queue(QueueName="test-queue")
|
||||
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
queue.receive_messages(WaitTimeSeconds=-1)
|
||||
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
queue.receive_messages(WaitTimeSeconds=21)
|
||||
|
||||
# no error but also no messages returned
|
||||
|
|
@ -1652,7 +1651,7 @@ def test_add_permission_errors():
|
|||
Actions=["ReceiveMessage"],
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.add_permission(
|
||||
QueueUrl=queue_url,
|
||||
Label="test",
|
||||
|
|
@ -1667,7 +1666,7 @@ def test_add_permission_errors():
|
|||
"Value test for parameter Label is invalid. " "Reason: Already exists."
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.add_permission(
|
||||
QueueUrl=queue_url,
|
||||
Label="test-2",
|
||||
|
|
@ -1683,7 +1682,7 @@ def test_add_permission_errors():
|
|||
"Reason: Only the queue owner is allowed to invoke this action."
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.add_permission(
|
||||
QueueUrl=queue_url,
|
||||
Label="test-2",
|
||||
|
|
@ -1698,7 +1697,7 @@ def test_add_permission_errors():
|
|||
"The request must contain the parameter Actions."
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.add_permission(
|
||||
QueueUrl=queue_url,
|
||||
Label="test-2",
|
||||
|
|
@ -1713,7 +1712,7 @@ def test_add_permission_errors():
|
|||
"Value [] for parameter PrincipalId is invalid. Reason: Unable to verify."
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.add_permission(
|
||||
QueueUrl=queue_url,
|
||||
Label="test-2",
|
||||
|
|
@ -1744,7 +1743,7 @@ def test_remove_permission_errors():
|
|||
response = client.create_queue(QueueName="test-queue")
|
||||
queue_url = response["QueueUrl"]
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.remove_permission(QueueUrl=queue_url, Label="test")
|
||||
ex = e.exception
|
||||
ex.operation_name.should.equal("RemovePermission")
|
||||
|
|
@ -1876,7 +1875,7 @@ def test_create_fifo_queue_with_dlq():
|
|||
)
|
||||
|
||||
# Cant have fifo queue with non fifo DLQ
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
sqs.create_queue(
|
||||
QueueName="test-queue2.fifo",
|
||||
Attributes={
|
||||
|
|
@ -1970,7 +1969,7 @@ def test_redrive_policy_available():
|
|||
assert json.loads(attributes["RedrivePolicy"]) == redrive_policy
|
||||
|
||||
# Cant have redrive policy without maxReceiveCount
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
sqs.create_queue(
|
||||
QueueName="test-queue2",
|
||||
Attributes={
|
||||
|
|
@ -1988,7 +1987,7 @@ def test_redrive_policy_non_existent_queue():
|
|||
"maxReceiveCount": 1,
|
||||
}
|
||||
|
||||
with assert_raises(ClientError):
|
||||
with pytest.raises(ClientError):
|
||||
sqs.create_queue(
|
||||
QueueName="test-queue",
|
||||
Attributes={"RedrivePolicy": json.dumps(redrive_policy)},
|
||||
|
|
@ -2173,7 +2172,7 @@ def test_send_messages_to_fifo_without_message_group_id():
|
|||
Attributes={"FifoQueue": "true", "ContentBasedDeduplication": "true"},
|
||||
)
|
||||
|
||||
with assert_raises(Exception) as e:
|
||||
with pytest.raises(Exception) as e:
|
||||
queue.send_message(MessageBody="message-1")
|
||||
ex = e.exception
|
||||
ex.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue