autodiscovery and autocreate tox testenv to aws lambda function
Project description
tox-lambda-autodiscovery
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:
- rewrite code when tox api is more flexible: https://mail.python.org/mm3/archives/list/tox-dev@python.org/thread/2B2GXTFWCE6FYMVCMBMKAOQAXEOGXEWR/
- Write tests
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_base_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_base_dirs = backend1
backend2
ignored_dir_names
Directories that the plugin should ignore in autodiscovery.
Example
ignored_dir_names = .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_dir_names = .serverless
search_base_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
Built Distribution
Hashes for tox-lambda-autodiscovery-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2aa86df8ae07e03b368797c124ed8a3ef6bd58d2053293a6fc02afe8d9b9e3 |
|
MD5 | 91e0cd198044bc9bf860ad3a218630d6 |
|
BLAKE2b-256 | 69361502449b7f499efd0ac333b753b7f7f187b65aadc7e321f5d99553d9cefb |
Hashes for tox_lambda_autodiscovery-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca62f37755b64f37bf07990553a3af9d6efbf8c0f3bf77c95e8946d0144a8165 |
|
MD5 | 43dce11ab4d2700d081b3ad701a615eb |
|
BLAKE2b-256 | 760f8ab625b3d564bcea0d05b51ca06fd659b4694838cee412d74f60318c10e1 |