Skip to content
Open
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- run: pip install -r requirements.txt pytest
- run: pytest -q
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# UserTask

[![CI](https://github.com/makambo13/UserTask/actions/workflows/ci.yml/badge.svg)](https://github.com/makambo13/UserTask/actions/workflows/ci.yml)

A small Flask app for a personal task list. Add a task with a title, a description and a priority, and the list shows the newest first.

<p align="center">
Expand All @@ -22,6 +24,12 @@ python run.py

Open http://127.0.0.1:5000. The SQLite database is created in `instance/` the first time the app starts.

## System design

![UserTask system design](docs/system-design.svg)

A request goes from the browser to the routes. The routes check the form, call `TaskService` to read or save tasks, and render a Jinja template back to the browser. Flask-Migrate manages the database schema. To edit the diagram, open `docs/system-design.excalidraw` at [excalidraw.com](https://excalidraw.com).

## How it works

- `tasks/routes.py` handles requests
Expand All @@ -30,3 +38,12 @@ Open http://127.0.0.1:5000. The SQLite database is created in `instance/` the fi
- `tasks/forms.py` has the Flask-WTF form

Not built yet: login, and editing, completing or deleting a task. Every task belongs to user 1.

## Tests and CI

```sh
pip install pytest
pytest -q
```

The 6 tests in `tests/` use an in-memory database, so they never touch `instance/tasks.db`. GitHub Actions runs them on Python 3.11, 3.12 and 3.13 for every push to `main` and every pull request.
6 changes: 5 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Initialize the db
db = SQLAlchemy()

def create_app():
def create_app(test_config=None):
app = Flask(__name__)

# Ensure instance folder exists
Expand All @@ -20,6 +20,10 @@ def create_app():
app.config['SQLALCHEMY_DATABASE_URI'] = f"sqlite:///{os.path.join(app.instance_path, 'tasks.db')}"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# Tests pass their own settings, such as an in-memory database
if test_config:
app.config.update(test_config)

# Initialize Migrate with app and db
migrate = Migrate(app, db)

Expand Down
Loading
Loading