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.

Source Distribution

tox-lambda-autodiscovery-0.1.6.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

tox_lambda_autodiscovery-0.1.6-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file tox-lambda-autodiscovery-0.1.6.tar.gz.

File metadata

  • Download URL: tox-lambda-autodiscovery-0.1.6.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for tox-lambda-autodiscovery-0.1.6.tar.gz
Algorithm Hash digest
SHA256 70375967324081a00331bee8addfd1a50a53e93ba7cc828462c21f9b3b8f43b5
MD5 b36e4002acb557740b71e368a697ad5c
BLAKE2b-256 d07fbd6e2ff80c827d4c025fb14951f3e3d836b523b83b47082c11a3904b91ab

See more details on using hashes here.

File details

Details for the file tox_lambda_autodiscovery-0.1.6-py2.py3-none-any.whl.

File metadata

  • Download URL: tox_lambda_autodiscovery-0.1.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for tox_lambda_autodiscovery-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8bef292e4142c57d05b01030e5d169b4e254dc9f2be157a9797eec59a0b22fe
MD5 3fd3227eada73e09488cd0e3ce2786de
BLAKE2b-256 d05d0137f8b9210e517d4559f5143251d05c3b6ed480495a93cea658c73c5103

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