This is a simple AWS SAM Python Base Template, where we can leverage the benfits of test driven development and follow the PEP-8 standard.
-
We have to write their code in the
srcdirectory with their testcases inside thetestsdirectory. -
The request/responce for the respective python module should be maintained inside the
tests/fixturesdirectory in.jsonformat. -
We can check their code by executing
python test.pyinside their terminal/command prompt.
If there is any error/warning in their code, we can watch the details inside the terminal/command prompt as shown in the picture above and fix accordingly
- Use the SAM CLI to build your docker image.
Build your application with this command-
sam-app$ sam build- Use the SAM CLI to test locally
This command will start the application locally-
sam local start-api- To invoke the application we can use terminal/postman.
This command invoke the application locally-
curl http://127.0.0.1:3000/First of all, you need to install docker and SAM CLI. Once you are done then clone this repo using terminal/command prompt after running-
git clone https://github.com/pranabsarkar/sam_python_tdd_base_template.git
Once, it is cloned move into the directory and open terminal/command prompt in the current directory and run this command to insatall the dependencies-
pip install -r requirements-local.txt
Open terminal/command prompt and run this command to execute the test suite-
python test.py
- PyTest
- flake8
- Test Driven Development
- AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
Please feel free to add your input's :)
