moto

How to get receipt handle from sqs queue response, getting(TypeError 'sqs.Message' object is not subscriptable

How to get receipt handle from sqs queue response, getting(TypeError 'sqs.Message' object is not subscriptable Question: I have one queue I’m sending some message in that and want to get receipt handle from output response. messages = queue.receive_messages() print(messages) I am receiving this type of response: [sqs.Message(queue_url=’someurl’, receipt_handle=’abcd’)] Now I want to extract only receipt …

Total answers: 1

What is the current, correct way to retrieve an SESBackend from Moto?

What is the current, correct way to retrieve an SESBackend from Moto? Question: I need access to the SESBackend object behind Moto’s mock_ses library, so that I can check sent messages have the right properties. The Moto documentation for SES currently only shows the basic decorator wrapping syntax. I’ve got something working, but it feels …

Total answers: 1

Applying moto on a classmethod fails

Applying moto on a classmethod fails Question: Applying a moto mock to the test class as a whole will have no effect on classmethods like the python unittests setupClass method. @mock_ssm class SomeClassTest(unittest.TestCase): @classmethod def setUpClass(cls) -> None: boto3.client("ssm").put_parameter(Name="some-name", Value="some-value") will result in botocore.exceptions.NoCredentialsError: Unable to locate credentials Asked By: Vincent Claes || Source Answers: …

Total answers: 1

SNS mocking with moto is not working correctly

SNS mocking with moto is not working correctly Question: In my unit test: def test_my_function_that_publishes_to_sns(): conn = boto3.client("sns", region_name="us-east-1") mock_topic = conn.create_topic(Name="mock-topic") topic_arn = mock_topic.get("TopicArn") os.environ["SNS_TOPIC"] = topic_arn # call my_function my_module.my_method() The the function being tested # inside my_module, my_function… sns_client.publish( TopicArn=os.environ["SNS_TOPIC"], Message="my message", ) I get the error: botocore.errorfactory.NotFoundException: An error occurred (NotFound) …

Total answers: 3

Moto sns client can't call create_topic AttributeError: 'generator' object has no attribute 'create_topic'

Moto sns client can't call create_topic AttributeError: 'generator' object has no attribute 'create_topic' Question: I’m trying to follow the docs to do this: @pytest.fixture() def aws_credentials(): """Mocked AWS Credentials for moto.""" os.environ["AWS_ACCESS_KEY_ID"] = "testing" os.environ["AWS_SECRET_ACCESS_KEY"] = "testing" os.environ["AWS_SECURITY_TOKEN"] = "testing" os.environ["AWS_SESSION_TOKEN"] = "testing" @pytest.fixture() def sts(aws_credentials): with mock_sts(): yield boto3.client("sts", region_name="us-east-1") @pytest.fixture def sns(aws_credentials): with …

Total answers: 1

how do I test methods using boto3 with moto

how do I test methods using boto3 with moto Question: I am writing test cases for a quick class to find / fetch keys from s3, using boto3. I have used moto in the past to test boto (not 3) code but am trying to move to boto3 with this project, and running into an …

Total answers: 2