2014-08-27 15:17:06 +00:00
|
|
|
from __future__ import unicode_literals
|
2021-09-22 21:50:27 +00:00
|
|
|
import sure # noqa
|
2013-12-26 16:12:50 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from boto.sqs.connection import SQSConnection
|
|
|
|
from boto.sqs.message import Message
|
|
|
|
from boto.ec2 import EC2Connection
|
2021-09-22 21:50:27 +00:00
|
|
|
import boto3
|
2013-12-26 16:12:50 +00:00
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
from moto import mock_sqs_deprecated, mock_ec2_deprecated
|
2021-09-22 21:50:27 +00:00
|
|
|
from moto import mock_sqs, mock_ec2
|
2021-01-29 11:31:56 +00:00
|
|
|
from tests import EXAMPLE_AMI_ID
|
2013-12-26 16:12:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestNestedDecorators(unittest.TestCase):
|
2021-09-22 21:50:27 +00:00
|
|
|
# Has boto3 equivalent
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_sqs_deprecated
|
2013-12-26 16:12:50 +00:00
|
|
|
def setup_sqs_queue(self):
|
|
|
|
conn = SQSConnection()
|
2019-10-31 15:44:26 +00:00
|
|
|
q = conn.create_queue("some-queue")
|
2013-12-26 16:12:50 +00:00
|
|
|
|
|
|
|
m = Message()
|
2019-10-31 15:44:26 +00:00
|
|
|
m.set_body("This is my first message.")
|
2013-12-26 16:12:50 +00:00
|
|
|
q.write(m)
|
|
|
|
|
|
|
|
self.assertEqual(q.count(), 1)
|
|
|
|
|
2021-09-22 21:50:27 +00:00
|
|
|
# Has boto3 equivalent
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_ec2_deprecated
|
2013-12-26 16:12:50 +00:00
|
|
|
def test_nested(self):
|
|
|
|
self.setup_sqs_queue()
|
|
|
|
|
|
|
|
conn = EC2Connection()
|
2021-01-29 11:31:56 +00:00
|
|
|
conn.run_instances(EXAMPLE_AMI_ID)
|
2021-09-22 21:50:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestNestedDecoratorsBoto3(unittest.TestCase):
|
|
|
|
@mock_sqs
|
|
|
|
def setup_sqs_queue(self):
|
|
|
|
conn = boto3.resource("sqs", region_name="us-east-1")
|
|
|
|
queue = conn.create_queue(QueueName="some-queue")
|
|
|
|
|
|
|
|
queue.send_message(MessageBody="test message 1")
|
|
|
|
|
|
|
|
queue.reload()
|
|
|
|
queue.attributes["ApproximateNumberOfMessages"].should.equal("1")
|
|
|
|
|
|
|
|
@mock_ec2
|
|
|
|
def test_nested(self):
|
|
|
|
self.setup_sqs_queue()
|
|
|
|
|
|
|
|
conn = boto3.client("ec2", region_name="us-west-2")
|
|
|
|
conn.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
|