Questions tagged [moto]

Moto is a Python library that allows you to easily mock out tests based on AWS infrastructure and the Boto library (an AWS SDK for python).

Moto is a Python library that allows you to easily mock out tests based on AWS infrastructure and the Boto library (an AWS SDK for python).

Related tags:

Links:

193 questions
0
votes
1 answer

Mock AWS s3 service in C#

I'm trying to mock AWS s3 service (more specifically the upload of files to s3), for that I'm using https://docs.getmoto.org/en/latest/docs/server_mode.html , the problem is I'm getting error during…
Andre
  • 652
  • 2
  • 7
  • 23
0
votes
1 answer

How to mock AWS athena/awswrangler with moto?

I am used to mocking most boto3 functionalities with moto. Recently, I encountered awswrangler to query athena and get the result as a nice pandas dataframe. wondering if there is a way to mock the functionality?
tandem
  • 2,040
  • 4
  • 25
  • 52
0
votes
0 answers

moto can't mock ec2 with securitygroup

I recently asked this question: moto unit test EC2 - 'NoneType' object has no attribute 'id' I now have at least found out about why this error occurs. I call ec2.run_instances() with multiple parameters, like this: ec2.run_instances( …
0
votes
1 answer

How to mock out AWS resources when testing flask app

I have a Flask app that uses AWS services such as dynamodb. I want to mock these out during unit tests but I'm having trouble doing so. Here is a minimal example that doesn't work for me: from flask import Flask import boto3 app =…
Daniel Kats
  • 5,141
  • 15
  • 65
  • 102
0
votes
2 answers

IndexError: list index out of range with moto

I am mocking an internal function which is returning dynamodb query. the query had begins_with which was throwing error IndexError: list index out of range. I changed the query and removed begins_with yet still getting the same error. If I remove…
Lovika
  • 577
  • 2
  • 10
  • 21
0
votes
1 answer

Moto how to create EC2 instance - InvalidAMIID.NotFound

Using moto how can you create an EC2 instance since theres no AMIs available to launch an instance with. This repo seems to be "pre-loading" AMIs that are later used within tests but im not sure how these are being…
mRyan
  • 332
  • 4
  • 18
0
votes
1 answer

Using moto to communiate with server

I'm trying to use moto to implement integration testing and trying to test some custom resources to be implemented with cloudformation. I'm using the example provided in the github page. I've slightly altered the example to fit my development…
Lukasz
  • 2,476
  • 10
  • 41
  • 51
0
votes
1 answer

ERROR: not found: (no name running python tests with moto, boto3 and python

Currently having difficulty running tests on a python file on my local machine meant to be deployed to AWS(I want to run the tests only on my local machine). The tests were implemented using unittest, boto3, moto and pytest. 2 files are contained in…
MIike Eps
  • 421
  • 7
  • 24
0
votes
0 answers

Tracking DynamoDB access with boto3

I need to make certain assertions in my unit tests about if particular DynamoDB tables were queried/mutated during a request. Is there any way I can intercept/hook-into boto3 calls to DynamoDB or maybe there's some kind of access log so I could read…
Gleb Kisenkov
  • 37
  • 1
  • 7
0
votes
1 answer

Mocking out AWS service in pytest references non-existent account

I'm trying to set up a mock service call to kinesis firehose. I'm importing mock_firehose from moto and referencing it as @mock_firehose. In the test method I've created a client using boto3. @mock_firehose def test_push_to_stream(push_record,…
Coder_Nick
  • 781
  • 1
  • 8
  • 25
0
votes
1 answer

TypeError: 'ec2.instancesCollectionManager' object is not iterable when mocking with Moto?

The following code got error of "TypeError: 'ec2.instancesCollectionManager' object is not iterable" when casting to list(instances) using Moto. @pytest.fixture(scope='function') def aws_credentials(): os.environ['AWS_ACCESS_KEY_ID'] =…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
0
votes
2 answers

Mocking AWS session.Session() got AttributeError: 'function' object has no attribute 'call_count'?

I need to write unit tests for the following class function, which returns the EC2 instances of AWS, to be tested. class C: def f(cls, session, filters): # .... instances =…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
0
votes
2 answers

How to develop lambda functions that depend on AWS triggers?

Lambda functions often get triggered by several AWS events (e.g an EventBridge event). I am developing a python lambda that once triggered by an EventBridge event (that matches a pattern for Security Hub), creates tickets on Jira. My question is:…
Dimi
  • 309
  • 5
  • 25
0
votes
1 answer

Python mocking using MOTO for SSM

Taken from this answer: Python mock AWS SSM I now have this code: test_2.py from unittest import TestCase import boto3 import pytest from moto import mock_ssm @pytest.yield_fixture def s3ssm(): with mock_ssm(): ssm =…
ck3mp
  • 391
  • 5
  • 18
0
votes
0 answers

Moto doesn't mock the db properly

What am I doing wrong here? This is my first time using moto and I'm really confused conftest.py: @pytest.fixture(scope='module') def dynamodb(aws_credentials): with mock_dynamodb2(): yield boto3.resource('dynamodb',…
AciD
  • 113
  • 3
  • 8