Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Jan 31 2019 22:19
    lightsgoout starred spulec/moto
  • Jan 31 2019 15:50
    drmorr0 commented #2030
  • Jan 31 2019 15:50
    drmorr0 commented #2032
  • Jan 31 2019 13:19
    Samir-Elsayed-Hub starred spulec/moto
  • Jan 31 2019 00:17
  • Jan 30 2019 18:19
    Brett55 commented #2035
  • Jan 30 2019 18:03
    dargueta commented #1886
  • Jan 30 2019 17:23
    dgea005 starred spulec/moto
  • Jan 30 2019 16:53
    sturmer opened #2040
  • Jan 30 2019 16:52
    perf123 commented #2038
  • Jan 30 2019 16:52
    perf123 closed #2038
  • Jan 30 2019 15:42
    jakul commented #1558
  • Jan 30 2019 15:40
    jakul commented #1558
  • Jan 30 2019 14:01
    perf123 edited #2038
  • Jan 30 2019 11:25
    craiga commented #2036
  • Jan 30 2019 07:26
    anshitmt edited #2039
  • Jan 30 2019 07:26
    anshitmt opened #2039
  • Jan 29 2019 22:50
    jayhale starred spulec/moto
  • Jan 29 2019 21:22
    mikegrima commented #1912
  • Jan 29 2019 21:19
    mikegrima commented #1886
does anyone have examples of how to use assert_called_with() against resources created by moto?
John Corrales
using assert_called_with() is just testing that you passed the right arguments to a function. you wouldn't necessarily use it to check created resources.

so i decided this SPECIFIC test was not actually useful (scrapped it) so ignore the uselessness of the test. i guess my confusion is regarding fixtures in general. when i call client.attach_volume.assert_called_with() against my moto client fixture i get error: AttributeError: 'function' object has no attribute 'assert_called_with'


def client(aws_credentials):
    with mock_ec2():
        yield boto3.client('ec2', region_name=REGION)


def attach_ebs_volume(client, instance_id, region):
    while utils.get_instance_state(client, instance_id) != "running":
        print("waiting for instance to start")
        #TODO: timeout

    for tag in utils.get_instance_tags(client, instance_id):
        if tag['Key'] == "volume":
            vol_tag = tag['Value']

    volume_id = utils.get_ebs_by_name_tag(client, vol_tag)

output from pytest:

    def test_attach_ebs_volume(mock_get_instance_tags, mock_get_instance_state, client):
        volume_id = client.create_volume(Size=7, AvailabilityZone=REGION, TagSpecifications=VOLUME_TAGS)['VolumeId']
        instance_id = client.run_instances(ImageId='ami-123', MinCount=1, MaxCount=1, TagSpecifications=INSTANCE_TAGS)['Instances'][0]['InstanceId']

        mock_get_instance_state.return_value = 'running'
        mock_get_instance_tags.return_value = RETURN_TAGS

        r = lambda_function.attach_ebs_volume(client,

>       client.attach_volume.assert_called_with(Device="/dev/xvdz",
E       AttributeError: 'function' object has no attribute 'assert_called_with'

i was trying to test that client.attach_volume gets the right values. again, this is not actually that useful of a test but the functionality probably will in future tests

Hi I am trying to mock lambda with moto, but keep getting this error when invoking a lambda: requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Tomer Shalev
Hi, is there an official Docker Hub release for moto?
Leo Shklovskii
Hi - what's the timeline for the next release? We'd love to see this fix released to clean up our CI logs: spulec/moto@882dfce
Asher Foa
@leos moto automatically releases a version on every commit to master. it is a pre-release, but if you are blocked by a fix that was merged, you can always pin the pre-release in your requirements file.
When the team eventually releases a new version of moto, it will basically be turning whatever the latest pre-releases available to be a regular release.
Having said that, I think it is time to do a moto release ;-)
Leo Shklovskii
Thanks @asherf ! it's not a blocker and you're right we can definitely target a github commit but we feel way more warm and fuzzy when it's a tagged version - and yes we'd love to see the team do an actual moto release :-)
Marcus Guimaraes
hey y'all, I need to mock an Organization that contains an account with a specific AWS ID, not the randomized value moto creates with orgs.create_account(). Are any of the following solutions feasible:
  1. call orgs.create_account(), then overwrite the ID of the account generated to match spec
  2. call orgs.create_account() in a way that forces the generated ID to be set to the spec ID
  3. mock an account join handshake procedure
Niraj Bhatt
Any update on next release? Need organization tags usage. Thanks.
Niraj Bhatt

hey y'all, I need to mock an Organization that contains an account with a specific AWS ID, not the randomized value moto creates with orgs.create_account(). Are any of the following solutions feasible:

  1. call orgs.create_account(), then overwrite the ID of the account generated to match spec
  2. call orgs.create_account() in a way that forces the generated ID to be set to the spec ID
  3. mock an account join handshake procedure

I think option 1 should work. I don't think option 2 is possible. No idea about option 3

Arcadiy Ivanov
Hello folks
There are a few things in S3 error handling that make no sense to me
I was wondering if someone could chime in before I start filing bugs
Here it seems a wrong template is used
Arcadiy Ivanov
And then I'm getting these weird failures where moto server is disregarding the exception and returns the code straight up: https://github.com/spulec/moto/pull/3021#issuecomment-633273171
Dawn James

hello! This is my first time here :wave:

Has anyone else noticed that test_streaming_upload_from_file_to_presigned_url is generating an error when it was fine yesterday? I can't find any existing open issues related to it, so I have raised an issue (spulec/moto#3080) and fixed it in a draft PR.

Advice would be appreciated :pray:

Dawn James
NB. the above PR is ready for review, and fixes two issues: the one mentioned above, and another issue that has been open for a while. Comments welcomed!
Leo Shklovskii
@spulec any updates on doing a release? If trunk is in good shape then a release should really be a no-op - would be great to have a new one
Anything I can do to help with making a release happen?
Dawn James
@leos maybe a release can happen after I finish spulec/moto#3082 which will add basic support for ApplicationAutoscaling
Vish Upadhyay
@spulec wondering why moto library depends on idna [required: >=2.5,<2.9]? I'm being forced to use idna-2.8 which was released on Dec4, 2018. My pipenv package manager fails for DependencyConflict as I have some other package in my environment that is installing idna-2.9.
Leon Mika

Hello. First time caller here.

I'm using moto to mock out SES and I want to verify that I've made a call to "send_raw_email". Poking around the code I've noticed that I can get the send messages from the "ses_backends". This solves my problem, but I'm just wondering if this is considered "best practice". How did others do this?

Dawn James
hi @vupadhyay - I've noticed this problem too, perhaps you would like to raise an issue? https://github.com/spulec/moto/issues/new
Since the lastest patch release breaks all our builds, when will the documentation be updated? I've raised issue here about the new requirement of the docker package: spulec/moto#3297
Mickey Pashov
Hey folks,
I haven't used Moto in anger in about 2 and a bit years
I recently joined a company where they have decided to move away from Moto as they say it's not compatible with the latest version of boto
I cursory search didn't yield any results
Is it true that moto doesn't support the more recent versions of boto?
Steve Pulec
Moto supports the latest version of boto3 and shouldn't have any problems with boto today. That being said, boto is a deprecated library so we will drop support at some point for boto directly. Boto would still work in server-based mode as would any client in any language.
Rob Reus
Hi all, currently implementing moto to test custom config rules. Running into the issue that the method "get_compliance_details_by_config_rule" is not implemented. What would be the easiest way to work around this? I dont care about the data returned by that method, an empty list is fine. Just want the test to succeed and not fail on a NotImplementedError. I have been able to get it to work by just adding a method to the models.py and responses.py files within the moto site-package, but of course this is not the way to go. Does anyone have an example on how to "hack" an extra method into a moto service mock?
Ciaran Evans
:wave: Is there a reason for the sequential-ness of the Travis builds?
I ask as a build is like ~3 hours and if there's a build already happening elsewhere on the repo (e.g. master) that adds another potential 3 hour lag time on your change being run
Hi guys! Maybe a stupid question - but how do I mock a method to raise an exception in Python? Let's say I need to mock sqs_queue.send_message(...) in order to simulate 500 error from the server. I could not find any code examples