Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 41 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Tailspin Toys Dev Container",
"image": "mcr.microsoft.com/devcontainers/universal:latest",
"postCreateCommand": "./scripts/setup-env.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csharp",
"GitHub.copilot",
"GitHub.copilot-chat",
"ms-python.vscode-pylance",
"svelte.svelte-vscode",
"astro-build.astro-vscode"
]
}
},
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "9.0"
}
}
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/schlich/devcontainer-features/playwright:0": {},
"ghcr.io/devcontainers-extra/features/typescript:2": {}
},
"postCreateCommand": "./scripts/setup-env.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csharp",
"GitHub.copilot",
"GitHub.copilot-chat",
"ms-python.vscode-pylance",
"svelte.svelte-vscode",
"astro-build.astro-vscode"
]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
4321,
5100
],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ updates:
dependency-type: production
update-types:
- patch
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"devcontainer",
"devcontainers",
"docstrings",
"dotnettools",
"isouter",
"prebuild",
"pylance",
"schlich",
"SDLC"
],
"github.copilot.nextEditSuggestions.enabled": true,
Expand Down
14 changes: 6 additions & 8 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"test:e2e": "npx playwright test"
"test:e2e": "npx playwright install && npx playwright test"
},
"dependencies": {
"@astrojs/node": "^9.3.0",
Expand Down
14 changes: 10 additions & 4 deletions server/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import os
from flask import Flask
from models import init_db
from routes.games import games_bp
from utils.database import init_db
from models import db
from utils.database import get_connection_string

# Get the server directory path
base_dir: str = os.path.abspath(os.path.dirname(__file__))

app: Flask = Flask(__name__)

# Initialize the database with the app
init_db(app)
# Configure and initialize the database
app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string()
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)

# Create tables
with app.app_context():
db.create_all()

# Register blueprints
app.register_blueprint(games_bp)
Expand Down
23 changes: 1 addition & 22 deletions server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,4 @@
# Import models after db is defined to avoid circular imports
from .category import Category
from .game import Game
from .publisher import Publisher

def init_db(app, testing: bool = False):
"""Initialize the database

Args:
app: The Flask application instance
testing: If True, allows reinitialization for testing
"""
if testing:
# For testing, we want to be able to reinitialize
db.init_app(app)
else:
try:
db.init_app(app)
except RuntimeError:
# Database already initialized
pass

# Create tables when initializing
with app.app_context():
db.create_all()
from .publisher import Publisher
4 changes: 2 additions & 2 deletions server/tests/test_games.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
from typing import Dict, List, Any, Optional
from flask import Flask, Response
from models import Game, Publisher, Category, db, init_db
from models import Game, Publisher, Category, db
from routes.games import games_bp

class TestGamesRoutes(unittest.TestCase):
Expand Down Expand Up @@ -52,7 +52,7 @@ def setUp(self) -> None:
self.client = self.app.test_client()

# Initialize in-memory database for testing
init_db(self.app, testing=True)
db.init_app(self.app)
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test setup is missing proper database teardown. According to the testing guidelines, tests should use db.engine.dispose() to properly close the database connection. Consider adding a tearDown method that calls db.engine.dispose() to ensure proper cleanup.

Copilot generated this review using guidance from repository custom instructions.

# Create tables and seed data
with self.app.app_context():
Expand Down
19 changes: 1 addition & 18 deletions server/utils/database.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import os
from models import init_db as models_init_db

def init_db(app, connection_string=None, testing=False):
"""
Initializes the database with the given Flask app and connection string.
If no connection string is provided, a default SQLite connection string is used.

Args:
app: The Flask application instance
connection_string: Optional database connection string
testing: If True, allows reinitialization for testing
"""
if connection_string is None:
connection_string = __get_connection_string()
app.config['SQLALCHEMY_DATABASE_URI'] = connection_string
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
models_init_db(app, testing=testing)

def __get_connection_string():
def get_connection_string() -> str:
"""
Returns the connection string for the database.
"""
Expand Down
12 changes: 9 additions & 3 deletions server/utils/seed_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import random
from flask import Flask
from models import db, Category, Game, Publisher
from utils.database import init_db
from utils.database import get_connection_string

def create_app():
"""Create and configure Flask app for database operations"""
app = Flask(__name__)

# Initialize the database with the app
init_db(app)
# Configure and initialize the database
app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string()
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)

# Create tables
with app.app_context():
db.create_all()

return app

Expand Down