Skip to main content

Automatically mocks resources from serverless.yml file.

Project description

pytest-serverless

Mock local resources for serverless framework.

master PyPI Python Licence
Build Status PyPI

Installation

pip install pytest-serverless

What problem it tries to solve?

When building your project with serverless most likely you will create resources like dynamodb tables, sqs queues, sns topics.

During writing tests you will have to mock those in moto.

This pytest plugin tries to automate this process by reading serverless.yml file and create mocks of resources for you.

Usage

Mark your test with @pytest.mark.usefixtures("serverless"), and rest will be done by plugin.

import boto3
import pytest


@pytest.mark.usefixtures("serverless")
def test():
    table = boto3.resource("dynamodb").Table("my-microservice.my-table")
    count_of_items = len(table.scan()["Items"])
    assert count_of_items == 0

Supported resources

AWS::DynamoDB::Table

AWS::SQS::Queue

Issues?

Plugin is in early stage of development, so you might find some bugs or missing functionality.

If possible create pull request (with tests) that fixes particular problem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-serverless, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_serverless-0.6.0-py3-none-any.whl (8.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pytest-serverless-0.6.0.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page