自动发现并自动创建aws lambda函数的tox testenv
tox-lambda-autodiscover的Python项目详细描述
毒性lambda自动发现
autodiscovery和autocreate tox testenv to aws lambda函数
这个Pytest插件是生成的 与Cookiecutter一起 @obestwalter的 Cookiecutter-tox-plugin 模板。
该项目尚未准备好投入生产。
功能
自动发现和自动创建tox testenv到aws lambda函数。
待办事项:
- []当ToxAPI更灵活时改写代码:https://mail.python.org/mm3/archives/list/tox-dev@python.org/thread/2B2GXTFWCE6FYMVCMBMKAOQAXEOGXEWR/
- []编写测试
要求
- python>;=3.6,tox>;=3.3.0
安装
您可以通过PyPI中的pip安装tox-lambda-autodiscovery
:
$ pip install tox-lambda-autodiscovery
或者直接从github:
$ pip install -e git+https://github.com/luzfcb/tox-lambda-autodiscovery@master#egg=tox-lambda-autodiscovery
用法
在tox.ini
上添加名为[testenv:lambdaautodiscovery]
的新节。
The plugin is active only when the section
[testenv:lambdaautodiscovery]
exists.
[testenv:lambdaautodiscovery]
的配置选项
search_dirs
插件用作自动发现的目录列表。默认值是{toxinidir}
。
示例
有一个目录列表,包含子目录,其中包含一个文件requirements.txt
,以及在同一目录级别上以test
开头的python文件:
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
search_base_dirs
看起来如下:
search_dirs=backend1 backend2
ignored_dirs
插件在自动发现中应忽略的目录。
示例
ignored_dirs = .serverless
.vscode
默认情况下,将忽略具有以下名称的目录:
.tox
__pycache__
eggs/
.eggs/
node_modules
If you want to override the default ignored directories names, use the option
default_ignored_dir_names
.
commands_workaround
是一种定制tox的方法commands
例如:
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
可以通过设置自定义PYTHONPATH
setenv =
PYTHONPATH = {toxinidir}/backend/
完整示例配置:
以下目录结构:
(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
配置:
[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
贡献
我们非常欢迎您的贡献。可以使用tox运行测试,请确保在提交请求之前覆盖率至少保持不变。
许可证
根据MIT许可证的条款发布,tox-lambda-autodiscovery
是免费的开源软件。
问题
如果您遇到任何问题,请file an issue连同详细说明。