This commit is contained in:
Jakub Miazek 2022-09-12 13:24:15 +02:00
parent 102771aee5
commit 9b1938c450
35 changed files with 50 additions and 50 deletions

View File

@ -12,7 +12,7 @@ RUN set -ex && pip install -r requirements.txt
FROM builder as final FROM builder as final
WORKDIR /code WORKDIR /code
COPY ./the_app/ /code/ COPY app/ /code/
COPY ./tests/ /code/ COPY ./tests/ /code/
COPY .env /code/ COPY .env /code/

View File

@ -26,7 +26,7 @@ migrate-create: ## create new alembic migration
.PHONY: requirements .PHONY: requirements
requirements: ## Refresh requirements.txt from pipfile.lock requirements: ## Refresh requirements.txt from pipfile.lock
pipenv run pip freeze >> requirements.txt pipenv lock --requirements --dev >| requirements.txt
.PHONY: test .PHONY: test
test: ## Run project tests test: ## Run project tests

View File

@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import create_async_engine
parent_dir = os.path.abspath(os.path.join(os.getcwd())) parent_dir = os.path.abspath(os.path.join(os.getcwd()))
sys.path.append(parent_dir) sys.path.append(parent_dir)
from the_app.models.base import Base as app_base from app.models.base import Base as app_base
target_metadata = app_base.metadata target_metadata = app_base.metadata

View File

@ -1,9 +1,9 @@
from fastapi import APIRouter, Depends, status from fastapi import APIRouter, Depends, status
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.nonsense import Nonsense from app.models.nonsense import Nonsense
from the_app.schemas.nnonsense import NonsenseResponse, NonsenseSchema from app.schemas.nnonsense import NonsenseResponse, NonsenseSchema
router = APIRouter(prefix="/v1/nonsense") router = APIRouter(prefix="/v1/nonsense")

View File

@ -1,8 +1,8 @@
from fastapi import APIRouter, Depends, status from fastapi import APIRouter, Depends, status
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.shakespeare import Paragraph from app.models.shakespeare import Paragraph
router = APIRouter(prefix="/v1/shakespeare") router = APIRouter(prefix="/v1/shakespeare")

View File

@ -2,10 +2,10 @@ from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.stuff import Stuff from app.models.stuff import Stuff
from the_app.schemas.stuff import StuffResponse, StuffSchema from app.schemas.stuff import StuffResponse, StuffSchema
from the_app.utils import get_logger from app.utils import get_logger
router = APIRouter(prefix="/v1/stuff") router = APIRouter(prefix="/v1/stuff")

View File

@ -3,7 +3,7 @@ from functools import lru_cache
from pydantic import BaseSettings from pydantic import BaseSettings
from the_app.utils import get_logger from app.utils import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View File

@ -5,7 +5,7 @@ from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from the_app import config from app import config
global_settings = config.get_settings() global_settings = config.get_settings()
url = global_settings.asyncpg_url url = global_settings.asyncpg_url

View File

@ -1,9 +1,9 @@
from fastapi import FastAPI from fastapi import FastAPI
from the_app.api.nonsense import router as nonsense_router from app.api.nonsense import router as nonsense_router
from the_app.api.stuff import router as stuff_router from app.api.stuff import router as stuff_router
from the_app.api.shakespeare import router as shakespeare_router from app.api.shakespeare import router as shakespeare_router
from the_app.utils import get_logger from app.utils import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

4
app/models/__init__.py Normal file
View File

@ -0,0 +1,4 @@
# for Alembic and unit tests
from app.models.stuff import * # noqa
from app.models.nonsense import * # noqa
from app.models.shakespeare import * # noqa

View File

@ -5,7 +5,7 @@ from sqlalchemy import Column, String, select
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.models.base import Base from app.models.base import Base
class Nonsense(Base): class Nonsense(Base):

View File

@ -13,7 +13,7 @@ from sqlalchemy import (
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from the_app.models.base import Base from app.models.base import Base
metadata = Base.metadata metadata = Base.metadata

View File

@ -5,7 +5,7 @@ from sqlalchemy import Column, String, select
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.models.base import Base from app.models.base import Base
class Stuff(Base): class Stuff(Base):

View File

@ -8,7 +8,7 @@ services:
- .env - .env
- .secrets - .secrets
command: bash -c " command: bash -c "
alembic upgrade head && uvicorn the_app.main:app alembic upgrade head && uvicorn app.main:app
--host 0.0.0.0 --port 8080 --host 0.0.0.0 --port 8080
--lifespan=on --use-colors --loop uvloop --http httptools --lifespan=on --use-colors --loop uvloop --http httptools
--reload --log-level debug --reload --log-level debug

View File

@ -1,9 +1,9 @@
from fastapi import APIRouter, Depends, status from fastapi import APIRouter, Depends, status
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.nonsense import Nonsense from app.models.nonsense import Nonsense
from the_app.schemas.nnonsense import NonsenseResponse, NonsenseSchema from app.schemas.nnonsense import NonsenseResponse, NonsenseSchema
router = APIRouter(prefix="/v1/nonsense") router = APIRouter(prefix="/v1/nonsense")

View File

@ -1,8 +1,8 @@
from fastapi import APIRouter, Depends, status from fastapi import APIRouter, Depends, status
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.shakespeare import Paragraph from app.models.shakespeare import Paragraph
router = APIRouter(prefix="/v1/shakespeare") router = APIRouter(prefix="/v1/shakespeare")

View File

@ -2,10 +2,10 @@ from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.database import get_db from app.database import get_db
from the_app.models.stuff import Stuff from app.models.stuff import Stuff
from the_app.schemas.stuff import StuffResponse, StuffSchema from app.schemas.stuff import StuffResponse, StuffSchema
from the_app.utils import get_logger from app.utils import get_logger
router = APIRouter(prefix="/v1/stuff") router = APIRouter(prefix="/v1/stuff")

View File

@ -3,7 +3,7 @@ from functools import lru_cache
from pydantic import BaseSettings from pydantic import BaseSettings
from the_app.utils import get_logger from app.utils import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View File

@ -5,7 +5,7 @@ from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from the_app import config from app import config
global_settings = config.get_settings() global_settings = config.get_settings()
url = global_settings.asyncpg_url url = global_settings.asyncpg_url

View File

@ -1,9 +1,9 @@
from fastapi import FastAPI from fastapi import FastAPI
from the_app.api.nonsense import router as nonsense_router from app.api.nonsense import router as nonsense_router
from the_app.api.stuff import router as stuff_router from app.api.stuff import router as stuff_router
from the_app.api.shakespeare import router as shakespeare_router from app.api.shakespeare import router as shakespeare_router
from the_app.utils import get_logger from app.utils import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View File

@ -1,4 +1,4 @@
# for Alembic and unit tests # for Alembic and unit tests
from the_app.models.stuff import * # noqa from app.models.stuff import * # noqa
from the_app.models.nonsense import * # noqa from app.models.nonsense import * # noqa
from the_app.models.shakespeare import * # noqa from app.models.shakespeare import * # noqa

View File

@ -5,7 +5,7 @@ from sqlalchemy import Column, String, select
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.models.base import Base from app.models.base import Base
class Nonsense(Base): class Nonsense(Base):

View File

@ -13,7 +13,7 @@ from sqlalchemy import (
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from the_app.models.base import Base from app.models.base import Base
metadata = Base.metadata metadata = Base.metadata

View File

@ -5,7 +5,7 @@ from sqlalchemy import Column, String, select
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from the_app.models.base import Base from app.models.base import Base
class Stuff(Base): class Stuff(Base):

View File

@ -2,9 +2,9 @@ import pytest
import pytest_asyncio import pytest_asyncio
from httpx import AsyncClient from httpx import AsyncClient
from the_app.database import engine from app.database import engine
from the_app.main import app from app.main import app
from the_app.models.base import Base from app.models.base import Base
@pytest.fixture( @pytest.fixture(

View File

@ -1,4 +0,0 @@
# for Alembic and unit tests
from the_app.models.stuff import * # noqa
from the_app.models.nonsense import * # noqa
from the_app.models.shakespeare import * # noqa