Skip to main content

autodiscovery and autocreate tox testenv to aws lambda function

Project description

tox-lambda-autodiscovery

PyPI version Python versions See Build Status on Travis CI See Build Status on AppVeyor Coverage Status

Autodiscovery and autocreate tox testenv to aws lambda functions


This Pytest plugin was generated with Cookiecutter along with @obestwalter's Cookiecutter-tox-plugin template.

This project is not yet ready for production.

Features

Autodiscovery and autocreate tox testenv to aws lambda function.

TODO:

Requirements

  • Python >= 3.6, tox >= 3.3.0

Installation

You can install tox-lambda-autodiscovery via pip from PyPI:

$ pip install tox-lambda-autodiscovery

or directly from github:

$ pip install -e git+https://github.com/luzfcb/tox-lambda-autodiscovery@master#egg=tox-lambda-autodiscovery

Usage

Add a new section named [testenv:lambdaautodiscovery] on tox.ini.

The plugin is active only when the section [testenv:lambdaautodiscovery] exists.

Configuration options for [testenv:lambdaautodiscovery]

search_dirs

A list of directories that the plugin uses as autodiscover. The default value is {toxinidir}.

Example

Having a list of directories, with subdirectories, which contains a file requirements.txt, and a python file started with test on the same directory level:

project:
       README.md
       backend1/
              serverless.yml
              package.json
              node_modules/
              functionCreateRole/
                   create_role.py
                   requirements.txt
                   test_create_role.py
       backend2/
              serverless.yml
              package.json
              node_modules/
              functionCreateUser/
                   create_user.py
                   requirements.txt
                   test_create_user.py

The search_base_dirs looks like the following:

search_dirs = backend1
              backend2

ignored_dirs

Directories that the plugin should ignore in autodiscovery.

Example
ignored_dirs = .serverless
               .vscode

The directories with the following names are ignored by default:

.tox
__pycache__
eggs/
.eggs/
node_modules

If you want to override the default ignored directories names, use the option default_ignored_dir_names.

the commands_workaround is a way to customize tox commands

eg.:

commands_workaround = {posargs:pytest} --cov={current_toxenv_lambda_dir} --basetemp={envtmpdir}

is ugly, but, tox 3.3.0 api has no simple way to defer processing of commands

The PYTHONPATH can be customized by setting

setenv =
    PYTHONPATH = {toxinidir}/backend/

Full sample config:

the following directories structure:

(myproject) fabio@luzfcb:~/projects$ tree myproject -L 2
myproject
├── README.md
├── backend
│   ├── README.md
│   ├── .serverless
│   │     ├── serverless-state.json
│   │     ├── cloudformation-template-create-stack.json
│   │     ├── functionOne
│   │     │     ├── requirements
│   │     │     └── requirements.txt
│   │     ├── functionTwo
│   │     │     ├── requirements
│   │     │     └── requirements.txt
│   ├── functionOne
│   │     ├── function_one.py
│   │     ├── test_function_one.py 
│   │     └── requirements.txt
│   ├── functionTwo
│   │     ├── function_two.py
│   │     ├── test_function_two.py 
│   │     └── requirements.txt
│   ├── apps
│   │     └── configure_django
│   │     │     └── __init__.py
│   │     └── myapp
│   │           ├── __init__.py
│   │           ├── apps.py
│   │           ├── models.py
│   │           └── migrations
│   └── serverless.yml
├── buildspec.yaml
├── cloudformation
│   └── dev-resources.yaml
├── codecov.yml
├── requirements.txt
├── requirements_dev.txt
├── setup.cfg
├── testspec.yaml
└── tox.ini

The configuration:

[testenv:lambdaautodiscovery]
commands_workaround = {posargs:pytest} --cov-append --cov={current_toxenv_lambda_dir} --basetemp={envtmpdir}

ignored_dirs = .serverless

search_dirs = backend

setenv =
    PYTHONPATH = {toxinidir}/backend/apps

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, tox-lambda-autodiscovery is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
tox_lambda_autodiscovery-0.1.6-py2.py3-none-any.whl (7.5 kB) Copy SHA256 hash SHA256 Wheel py2.py3
tox-lambda-autodiscovery-0.1.6.tar.gz (7.1 kB) Copy SHA256 hash SHA256 Source None

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