Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Test Driven Development for web summarizer project with fastapi and implementing Containerization, CI/CD method, github action workflows and deployment

NotificationsYou must be signed in to change notification settings

sanggusti/fastapi-tdd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Continuous Integration and Delivery

Overview

This project is delivering backend service of page summarizer using various stacks that are pivoting aroundfastapi,docker,postgresql,pytest andnltk. Dedicated to develop based on test driven as best practice in software development and also with Continuous Integration and Continuous Development.

How to use

For development :

Simply clone,docker-compose up -d --build and redirect tohttp://localhost:8004/docs. To do unit test, executedocker-compose exec python -m pytest.

For usage as service :

  • Adding a new summary
$ http --json POST https://evening-brook-44287.herokuapp.com/summaries/ url=https://your_url.etc

example:

$ http --json POST http://localhost:8004/summaries/ url=http://testdriven.ioHTTP/1.1 201 Createdcontent-length: 34content-type: application/jsondate: Sun, 10 May 2020 15:59:54 GMTserver: uvicorn{    "id": 5,    "url": "http://testdriven.io"}
  • Get the summary
$ http GET https://evening-brook-44287.herokuapp.com/summaries/{output_id}/

example

$ http GET http://localhost:8004/summaries/5/HTTP/1.1 200 OKcontent-length: 134content-type: application/jsondate: Sun, 10 May 2020 16:00:09 GMTserver: uvicorn{    "created_at": "2020-05-10T15:59:55.098074",    "id": 5,    "summary": "",    "url": "http://testdriven.io"}

feel free to try hit this service as api to your webapp!

Objectives

  • Develop an asynchronous RESTful API with Python and FastAPI
  • Practice Test-Driven Development
  • Test a FastAPI app with pytest
  • Interact with a Postgres database asynchronously
  • Containerize FastAPI and Postgres inside a Docker container
  • Run unit and integration tests with code coverage inside a Docker container
  • Check your code for any code quality issues via a linter
  • Configure GitHub Actions for continuous integration and deployment
  • Use GitHub Packages to store Docker Images
  • Speed up a Docker-based CI build with Docker Cache
  • Deploy FastAPI, Uvicorn, and Postgres to Heroku with Docker
  • Parameterize test functions and mock functionality in tests with pytest
  • Run tests in parallel with pytest-xdist
  • Document a RESTful API with Swagger/OpenAPI
  • Run a background process outside the request/response flow

Project Structure

├── .github│   └── workflows│       └── main.yml├── .gitignore├── README.md├── docker-compose.yml├── project│   ├── .coverage│   ├── .coveragerc│   ├── .dockerignore│   ├── Dockerfile│   ├── Dockerfile.prod│   ├── app│   │   ├── __init__.py│   │   ├── api│   │   │   ├── __init__.py│   │   │   ├── crud.py│   │   │   ├── ping.py│   │   │   └── summaries.py│   │   ├── config.py│   │   ├── db.py│   │   ├── main.py│   │   ├── models│   │   │   ├── __init__.py│   │   │   ├── pydantic.py│   │   │   └── tortoise.py│   │   └── summarizer.py│   ├── db│   │   ├── Dockerfile│   │   └── create.sql│   ├── entrypoint.sh│   ├── htmlcov│   ├── requirements-dev.txt│   ├── requirements.txt│   ├── setup.cfg│   └── tests│       ├── __init__.py│       ├── conftest.py│       ├── test_ping.py│       ├── test_summaries.py│       └── test_summaries_unit.py└── release.sh

About

Test Driven Development for web summarizer project with fastapi and implementing Containerization, CI/CD method, github action workflows and deployment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

[8]ページ先頭

©2009-2026 Movatter.jp