Skip to main content

py-event-mocks

Python implementation of serverless / event-mocks

A small library that includes details mocks of AWS Lambda event sources, same with original event-mocks. Useful for use when unit testing your Lambda functions. Supported Event Sources are:

  • API Gateway
  • SNS
  • SQS
  • DynamoDB
  • S3
  • Scheduled
  • Websocket
  • Alexa Skill
  • Alexa Smart Home
  • CloudWatch
  • CloudWatch Log
  • Cognito Pool
  • IoT
  • AWS Batch

The library simply uses default event source mock templates and merge it with any overwrite you provide. Check out the JSON template files to learn more about the data structure of each event source.

Set up

pip install py-event-mocks

Usage

from py_event_mocks import create_event

event = create_event("aws:s3")

# event would be
#   {
#     "Records": [
#       {
#         "eventVersion": "2.0",
#         "eventSource": "aws:s3",
#         "awsRegion": "us-east-1",
#     ...
#   }

Allowed event_type (first parameter) is as follows:

  • "aws:alexa-skill-event"
  • "aws:alexa-smart-home-event"
  • "aws:api-gateway-event"
  • "aws:cloud-watch-event"
  • "aws:cloud-watch-log-event"
  • "aws:cognito-user-pool-event"
  • "aws:dynamo-stream-event"
  • "aws:kinesis"
  • "aws:s3"
  • "aws:scheduled"
  • "aws:sns"
  • "aws:sqs"

You can overwrite default template with "body" parameter.

event = create_event(
    event_type="aws:s3",
    body={
      "Records": [{
        "eventName": "ObjectCreated:Put",
        "s3": {
          "bucket": {
            "name": "my-bucket-name"
          },
          "object": {
            "key": "object-key"
          }
        }
      }]
    }
)

Metadata

Release files for py-event-mocks 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-event-mocks 0.0.4
File Size Uploaded
py-event-mocks-0.0.4.tar.gz 9.4 kB Details

Release files / py-event-mocks-0.0.4.tar.gz

Download URL py-event-mocks-0.0.4.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ba5f977780761b200fa7c8d94fe424b38120f2c4c11a7a4c8120f8946195b85d
BLAKE2b-256 checksum
How to use checksums
07780ad76024b82625b8c61d162dd727e60ae40ad5d058a5618324ebbe8bae8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page