From af040f8e926f94b5066eccd6af99c2b828093b7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:07:51 +0000 Subject: [PATCH 1/4] Initial plan From 539dbdee53738714dfe96565db17907c74bec7b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:12:06 +0000 Subject: [PATCH 2/4] Add example model step for FastAPI test setup Co-authored-by: SupraSummus <15822143+SupraSummus@users.noreply.github.com> --- fastapi/35-example-model.sh | 96 +++++++++++++++++++++++++++++++++++++ fastapi/test.sh | 1 + 2 files changed, 97 insertions(+) create mode 100755 fastapi/35-example-model.sh diff --git a/fastapi/35-example-model.sh b/fastapi/35-example-model.sh new file mode 100755 index 0000000..e0fd0b1 --- /dev/null +++ b/fastapi/35-example-model.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# This step adds an example model with CRUD routes and tests. +# It is NOT included in everything.sh — it exists solely to verify +# that the scaffolded app can easily be extended with new models. + +# Determine project name if not set +if [[ -z "$FASTAPI_PROJECT_NAME" ]]; then + FASTAPI_PROJECT_NAME=$(basename "$PWD") + FASTAPI_PROJECT_NAME=${FASTAPI_PROJECT_NAME//[-.]/_} + export FASTAPI_PROJECT_NAME +fi + +# Create example model with router +cat > "$FASTAPI_PROJECT_NAME/example.py" <> "test_app.py" < Date: Fri, 6 Feb 2026 15:23:21 +0000 Subject: [PATCH 3/4] Address review: test_create asserts db entry, test_get seeds db directly Co-authored-by: SupraSummus <15822143+SupraSummus@users.noreply.github.com> --- fastapi/35-example-model.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fastapi/35-example-model.sh b/fastapi/35-example-model.sh index e0fd0b1..1e4db4b 100755 --- a/fastapi/35-example-model.sh +++ b/fastapi/35-example-model.sh @@ -58,6 +58,9 @@ EOF sed -i '/^from fastapi import FastAPI/a from .example import router as example_router' "$FASTAPI_PROJECT_NAME/main.py" sed -i '/^app = FastAPI()/a app.include_router(example_router)' "$FASTAPI_PROJECT_NAME/main.py" +# Add example model import to test file +sed -i "/^from ${FASTAPI_PROJECT_NAME}.main import app/a from ${FASTAPI_PROJECT_NAME}.example import ExampleItem, _examples_db" "test_app.py" + # Add example model tests cat >> "test_app.py" < Date: Fri, 6 Feb 2026 15:36:38 +0000 Subject: [PATCH 4/4] Rewrite example model step to use real PostgreSQL with SQLAlchemy Co-authored-by: SupraSummus <15822143+SupraSummus@users.noreply.github.com> --- .github/workflows/test.yaml | 2 + fastapi/35-example-model.sh | 154 +++++++++++++++++++++++++----------- 2 files changed, 111 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 386fd7a..cc01ab2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,6 +17,8 @@ jobs: - run: ./test.sh working-directory: flask - run: ./fastapi/test.sh + env: + DATABASE_URL: postgresql+asyncpg://postgres:postgrespass@localhost:5432/postgres services: postgres: diff --git a/fastapi/35-example-model.sh b/fastapi/35-example-model.sh index 1e4db4b..d018fad 100755 --- a/fastapi/35-example-model.sh +++ b/fastapi/35-example-model.sh @@ -1,6 +1,7 @@ #!/bin/bash -# This step adds an example model with CRUD routes and tests. +# This step adds an example SQLAlchemy model with CRUD routes and tests +# using a real PostgreSQL database. # It is NOT included in everything.sh — it exists solely to verify # that the scaffolded app can easily be extended with new models. @@ -11,90 +12,153 @@ if [[ -z "$FASTAPI_PROJECT_NAME" ]]; then export FASTAPI_PROJECT_NAME fi -# Create example model with router +# Install pytest-asyncio for async test support +poetry add --group dev 'pytest-asyncio==*' + +# Create example SQLAlchemy model with routes cat > "$FASTAPI_PROJECT_NAME/example.py" < "conftest.py" <> "test_app.py" < "test_app.py" <