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.

Source Distribution

pytest-serverless-0.7.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_serverless-0.7.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest-serverless-0.7.0.tar.gz.

File metadata

  • Download URL: pytest-serverless-0.7.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0a2 CPython/3.6.5 Darwin/19.0.0

File hashes

Hashes for pytest-serverless-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f0e4854a22f4570bd7a200e61a0ba36bf557147f685c5a3853c9a17d7828c3bd
MD5 f788b2e812e44d88d4bec8ecc0d1131b
BLAKE2b-256 a2c503aba1cbfcf7a75f8745271f6852195959dfa03258142557e2d654f04937

See more details on using hashes here.

File details

Details for the file pytest_serverless-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_serverless-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0a2 CPython/3.6.5 Darwin/19.0.0

File hashes

Hashes for pytest_serverless-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c0454bdd2e21dbb8150f82333f764dd137e11638a28b94cb2619f629d7a1f8e
MD5 0e4352ab7f867ff356ea9f89219f6fa4
BLAKE2b-256 d1614945e7b580ddfc18077746e5818a2e238aef4f8b09b6b6d713708baf75b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page