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

Commit fda53aa

Browse files
committed
update dependencies
1 parent 5c2d908 commit fda53aa

File tree

9 files changed

+22
-25
lines changed

9 files changed

+22
-25
lines changed

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Michael Herman
3+
Copyright (c) 2021 Michael Herman
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Developing and Testing an API with FastAPI and Pytest
22

3-
Syncronous Example
3+
Synchronous Example
44

55
## Want to use this project?
66

‎docker-compose.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
version: '3.7'
1+
version: '3.8'
22

33
services:
44
web:
55
build: ./src
6-
command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000
6+
command: |
7+
bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000'
78
volumes:
89
- ./src/:/usr/src/app/
910
ports:
1011
- 8003:8000
1112
environment:
1213
- DATABASE_URL=postgresql://hello_fastapi:hello_fastapi@db/hello_fastapi_dev
1314
db:
14-
image: postgres:12.1-alpine
15+
image: postgres:13-alpine
1516
volumes:
1617
- postgres_data:/var/lib/postgresql/data/
18+
expose:
19+
- 5432
1720
environment:
1821
- POSTGRES_USER=hello_fastapi
1922
- POSTGRES_PASSWORD=hello_fastapi

‎src/Dockerfile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pull official base image
2-
FROM python:3.8.1-alpine
2+
FROM python:3.9.4-alpine
33

44
# set work directory
55
WORKDIR /usr/src/app
@@ -15,10 +15,10 @@ COPY ./requirements.txt /usr/src/app/requirements.txt
1515
RUN set -eux \
1616
&& apk add --no-cache --virtual .build-deps build-base \
1717
libressl-dev libffi-dev gcc musl-dev python3-dev \
18-
postgresql-dev \
18+
postgresql-dev bash \
1919
&& pip install --upgrade pip setuptools wheel \
2020
&& pip install -r /usr/src/app/requirements.txt \
2121
&& rm -rf /root/.cache/pip
2222

2323
# copy project
24-
COPY . /usr/src/app/
24+
COPY . /usr/src/app/

‎src/app/api/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pydantic import BaseModel, Field
2-
from sqlalchemy.sql import func
32
from sqlalchemy import Column, Integer, String, DateTime
3+
from sqlalchemy.sql import func
44

55
from app.db import Base
66

‎src/app/api/notes.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import List
2-
fromsqlalchemy.ormimportSession
2+
33
from fastapi import APIRouter, Depends, HTTPException, Path
4+
from sqlalchemy.orm import Session
45

5-
from app.db import SessionLocal
66
from app.api import crud
77
from app.api.models import NoteDB, NoteSchema
8+
from app.db import SessionLocal
89

910

1011
router = APIRouter()

‎src/app/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from fastapi import FastAPI
22

3-
from app.db import engine
43
from app.api import ping, notes
54
from app.api.models import Base
5+
from app.db import engine
66

77

88
Base.metadata.create_all(bind=engine)

‎src/requirements.txt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
fastapi==0.45.0
2-
psycopg2-binary==2.8.4
3-
SQLAlchemy==1.3.12
4-
uvicorn==0.11.1
1+
fastapi==0.63.0
2+
psycopg2-binary==2.8.6
3+
SQLAlchemy==1.3.24
4+
uvicorn==0.13.4
55

66
# dev
7-
pytest==5.3.2
8-
requests==2.22.0
7+
pytest==6.2.3
8+
requests==2.25.1

‎src/tests/test_ping.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
from starlette.testclient import TestClient
2-
3-
from app.main import app
4-
5-
client = TestClient(app)
6-
7-
81
def test_ping(test_app):
92
response = test_app.get("/ping")
103
assert response.status_code == 200

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /