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
4 changes: 2 additions & 2 deletions A TESTER et DOCUMENTER/TEST_OK/fk-reservation-lignearticle.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Cette FK est la premiere etape pour decouplage de Stripe :
1. Admin → Evenements → choisir un evenement
2. Creer une reservation via l'admin (moyen de paiement : Especes)
3. Verifier en base :
docker exec lespass_django poetry run python manage.py shell -c "
docker exec lespass_django uv run manage.py shell -c "
from BaseBillet.models import LigneArticle
for l in LigneArticle.objects.filter(sale_origin='AD').order_by('-datetime')[:3]:
print(l.uuid, l.reservation_id, l.paiement_stripe_id)
Expand Down Expand Up @@ -94,7 +94,7 @@ Cette FK est la premiere etape pour decouplage de Stripe :

```
Verifier que les lignes existantes ont ete backfillees :
docker exec lespass_django poetry run python manage.py shell -c "
docker exec lespass_django uv run manage.py shell -c "
from BaseBillet.models import LigneArticle
total = LigneArticle.objects.filter(paiement_stripe__reservation__isnull=False).count()
filled = LigneArticle.objects.filter(reservation__isnull=False).count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ a chaque clic. Resultat : doubles prelevements SEPA.

Verification en base :
```bash
docker exec lespass_django poetry run python manage.py shell -c "
docker exec lespass_django uv run manage.py shell -c "
from BaseBillet.models import Membership, Paiement_stripe
m = Membership.objects.get(uuid='<UUID>')
print('Nb paiements:', m.stripe_paiement.count())
Expand Down
2 changes: 1 addition & 1 deletion Administration/management/commands/get_login_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def add_arguments(self, parser):
python manage.py get_login_link user@example.com mytenant

Via Docker :
docker exec lespass_django poetry run python manage.py get_login_link user@example.com mytenant
docker exec lespass_django uv run manage.py get_login_link user@example.com mytenant
"""
parser.add_argument('email', type=str, help="L'email de l'utilisateur")
parser.add_argument('schema_name', type=str, help="Le schema_name du tenant")
Expand Down
2 changes: 1 addition & 1 deletion Administration/management/commands/launch_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def add_arguments(self, parser):
python manage.py launch_payment user@example.com mytenant 1000

Via Docker :
docker exec lespass_django poetry run python manage.py launch_payment user@example.com mytenant 1000
docker exec lespass_django uv run manage.py launch_payment user@example.com mytenant 1000
"""
parser.add_argument('email', type=str, help="L'email de l'utilisateur qui paye")
parser.add_argument('schema_name', type=str, help="Le schema_name du tenant (lieu de vente)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
for a tenant and allow a fresh handshake from scratch.

Usage :
docker exec lespass_django poetry run python manage.py reset_cashless_handshake --tenant <schema_name>
docker exec lespass_django uv run manage.py reset_cashless_handshake --tenant <schema_name>
"""

import logging
Expand Down
2 changes: 1 addition & 1 deletion Administration/management/commands/test_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Command(BaseCommand):
"""
docker exec lespass_django poetry run python manage.py test_api_key
docker exec lespass_django uv run manage.py test_api_key
"""
def handle(self, *args, **options):
if not settings.TEST:
Expand Down
28 changes: 14 additions & 14 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
C'est une brique de l'ecosysteme TiBillet (avec LaBoutik pour la caisse/cashless et Fedow pour le portefeuille federe).
Fabrique par la Cooperative Code Commun, licence AGPLv3.

Stack : Django 4.2, Python 3.11, Django REST Framework, PostgreSQL 13, Redis, Memcached, Celery, Poetry, Docker.
Stack : Django 4.2, Python 3.11, Django REST Framework, PostgreSQL 13, Redis, Memcached, Celery, UV, Docker.

## FALC — Principe fondamental

Expand Down Expand Up @@ -159,7 +159,7 @@ Vocabulaire schema.org avec champs JSON-LD. Voir `api_v2/GUIDELINES.md` pour le

```bash
# Lance dans le terminal actuel ET garde un trace dans un fichier de log :
docker exec lespass_django poetry run python /DjangoFiles/manage.py runserver 0.0.0.0:8002 2>&1 | tee /DjangoFiles/logs/runserver.log
docker exec lespass_django uv run /DjangoFiles/manage.py runserver 0.0.0.0:8002 2>&1 | tee /DjangoFiles/logs/runserver.log
```

Les logs du serveur (tracebacks, requetes) sont ecrits dans un fichier temporaire :
Expand All @@ -175,21 +175,21 @@ tail -f logs/runserver.log
docker compose up -d

# Commandes Django dans le conteneur
docker exec lespass_django poetry run python manage.py <commande>
docker exec lespass_django uv run manage.py <commande>

# Migrations multi-tenant
docker exec lespass_django poetry run python manage.py migrate_schemas --executor=multiprocessing
docker exec lespass_django uv run manage.py migrate_schemas --executor=multiprocessing

# Collectstatic
docker exec lespass_django poetry run python manage.py collectstatic --no-input
docker exec lespass_django uv run manage.py collectstatic --no-input

# i18n
docker exec lespass_django poetry run django-admin makemessages -l fr
docker exec lespass_django poetry run django-admin makemessages -l en
docker exec lespass_django poetry run django-admin compilemessages
docker exec lespass_django uv run django-admin makemessages -l fr
docker exec lespass_django uv run django-admin makemessages -l en
docker exec lespass_django uv run django-admin compilemessages

# Celery (lance via docker-compose, commande pour reference)
poetry run celery -A TiBillet worker -l INFO -B --concurrency=6
uv run celery -A TiBillet worker -l INFO -B --concurrency=6
```

## Tests
Expand All @@ -198,16 +198,16 @@ poetry run celery -A TiBillet worker -l INFO -B --concurrency=6

```bash
# Tous les tests API
poetry run pytest tests/pytest/ -v
uv run pytest tests/pytest/ -v

# Tests integration API v2 uniquement
poetry run pytest -m integration tests/pytest/
uv run pytest -m integration tests/pytest/

# Un seul fichier
poetry run pytest tests/pytest/test_events_list.py -qs
uv run pytest tests/pytest/test_events_list.py -qs

# Avec cle API
poetry run pytest tests/pytest --api-key <KEY> --api-base-url https://lespass.tibillet.localhost
uv run pytest tests/pytest --api-key <KEY> --api-base-url https://lespass.tibillet.localhost
```

### E2E (Playwright)
Expand All @@ -224,7 +224,7 @@ Les tests sont numerotes pour l'ordre d'execution (01 a 24+). Carte Stripe test

Verification DB apres un test E2E :
```bash
docker exec lespass_django poetry run python manage.py verify_test_data --type reservation --email <EMAIL>
docker exec lespass_django uv run manage.py verify_test_data --type reservation --email <EMAIL>
```

### Regles d'ecriture des tests
Expand Down
2 changes: 1 addition & 1 deletion PLANS/PLAN_BOOKING_EASY_RESERVATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Le back sera code dans un plan ulterieur. Pour l'instant on pose juste le bouton
## Verification

```bash
docker exec lespass_django poetry run python manage.py check
docker exec lespass_django uv run manage.py check

# Manuellement :
# 1. Se connecter
Expand Down
2 changes: 1 addition & 1 deletion PLANS/PLAN_TEST_BOOKING_EASY_RESERVATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
2. Aller sur `/event/<slug-freeres>/`
3. Cliquer sur `[data-testid="booking-easy-reservation"]`
4. Verifier la reponse (redirection ou message de confirmation)
5. Verifier en DB : `docker exec lespass_django poetry run python manage.py verify_test_data --type reservation --email <EMAIL>`
5. Verifier en DB : `docker exec lespass_django uv run manage.py verify_test_data --type reservation --email <EMAIL>`
16 changes: 8 additions & 8 deletions api_v2/GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ These guidelines define how to build the v2 API with a strong focus on semantic,
- Granular authorization per resource/action with custom DRF permission classes defined in this folder.
- Keys must be manageable from Django admin.
- Testing strategy
- Use Poetry to run tests: `poetry install` then `poetry run pytest`.
- Example: `poetry run pytest -q tests/pytest/test_events_list.py`.
- Use UV to run tests: `uv sync` then `uv run pytest`.
- Example: `uv run pytest -q tests/pytest/test_events_list.py`.
- Unit/integration tests run with plain pytest (not Django `manage.py test`).
- Prefer black-box HTTP calls against a dev hostname like `lespass.tibillet.localhost`.
- Keep tests in standalone Python scripts under `tests/` or project-level `tests/` executed by `pytest`.
Expand Down Expand Up @@ -132,24 +132,24 @@ Usage notes
- DELETE /api/v2/events/{uuid}/ → delete an Event by UUID. Response 204 on success.
- Authentication
- Send header: `Authorization: Api-Key <your_key>`
- Running tests (Poetry)
- `poetry install`
- `poetry run pytest -qs tests/pytest`
- Running tests (UV)
- `uv sync`
- `uv run pytest -qs tests/pytest`
- Tests are ordered to run in the following sequence for Event CRUD: create → list → retrieve → delete. A `conftest.py` hook enforces this order.
- The create test also stores the created `identifier` and `name` in pytest cache; subsequent tests read from this cache to make assertions independent of demo data.



---

## Running tests with Poetry and API key
## Running tests with UV and API key

You can pass the API key (and optionally the base URL) directly via pytest CLI flags.

Examples:

- `poetry run pytest -qs tests/pytest --api-key <YOUR_KEY>`
- `poetry run pytest -qs tests/pytest --api-key <YOUR_KEY> --api-base-url https://lespass.tibillet.localhost`
- `uv run pytest -qs tests/pytest --api-key <YOUR_KEY>`
- `uv run pytest -qs tests/pytest --api-key <YOUR_KEY> --api-base-url https://lespass.tibillet.localhost`

Notes:
- The `--api-key` and `--api-base-url` flags are injected into environment variables `API_KEY` and `API_BASE_URL` by a session fixture in `tests/pytest/conftest.py`.
Expand Down
4 changes: 2 additions & 2 deletions api_v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ OpenAPI / Auto‑generated docs (drf-spectacular)
- Redoc UI: GET `/api/schema/redoc/`
- Scope: schema generation is limited to `/api/v2/...` endpoints via `SPECTACULAR_SETTINGS['SCHEMA_PATH_PREFIX'] = r'/api/v2'`.

Export the schema file (with Poetry)
- `poetry run python manage.py spectacular --color --file api_v2/openapi-schema.yaml`
Export the schema file (with UV)
- `uv run manage.py spectacular --color --file api_v2/openapi-schema.yaml`
- Add `--validate` to also validate against the OpenAPI spec

Example response
Expand Down
26 changes: 13 additions & 13 deletions bashrc
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# only for convenient :)

alias mm="poetry run python /DjangoFiles/manage.py migrate"
alias sp="poetry run python manage.py tenant_command shell_plus --print-sql"
alias mm="uv /DjangoFiles/manage.py migrate"
alias sp="uv run manage.py tenant_command shell_plus --print-sql"

alias rsp="poetry run python /DjangoFiles/manage.py runserver 0.0.0.0:8002 2>&1 | tee /DjangoFiles/runserver.log"
alias rsp="uv run /DjangoFiles/manage.py runserver 0.0.0.0:8002 2>&1 | tee /DjangoFiles/runserver.log"

alias guni="poetry run python /DjangoFiles/manage.py collectstatic --no-input && poetry run gunicorn TiBillet.wsgi --capture-output --reload -w 3 -b 0.0.0.0:8002 2>&1 | tee /DjangoFiles/runserver.log"
alias guni="uv run /DjangoFiles/manage.py collectstatic --no-input && uv run gunicorn TiBillet.wsgi --capture-output --reload -w 3 -b 0.0.0.0:8002 2>&1 | tee /DjangoFiles/runserver.log"

alias cel="poetry run celery -A TiBillet worker -l INFO"
alias cel="uv run celery -A TiBillet worker -l INFO"

alias test="poetry run python /DjangoFiles/manage.py test"
alias test="uv run /DjangoFiles/manage.py test"

alias mmes="poetry run python manage.py makemessages -l en && poetry run python manage.py makemessages -l fr"
alias cmes="poetry run python manage.py compilemessages"
alias mmes="uv run manage.py makemessages -l en && uv run manage.py makemessages -l fr"
alias cmes="uv run manage.py compilemessages"

alias pshell="eval $(poetry env activate)"
alias pshell="source .venv/bin/activate"

tibinstall() {
poetry run python /DjangoFiles/manage.py collectstatic
poetry run python /DjangoFiles/manage.py migrate
poetry run python /DjangoFiles/manage.py create_public
uv run /DjangoFiles/manage.py collectstatic
uv run /DjangoFiles/manage.py migrate
uv run /DjangoFiles/manage.py create_public
echo "Création du super utilisateur :"
poetry run python /DjangoFiles/manage.py create_tenant_superuser -s public
uv run /DjangoFiles/manage.py create_tenant_superuser -s public
}

load_sql() {
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ services:
- lespass.tibillet.localhost:172.17.0.1
- laboutik.tibillet.localhost:172.17.0.1
- laboutik2.tibillet.localhost:172.17.0.1
command: "poetry run celery -A TiBillet worker -l INFO -B --concurrency=6"
command: "uv run celery -A TiBillet worker -l INFO -B --concurrency=6"


lespass_nginx:
Expand Down Expand Up @@ -206,7 +206,7 @@ volumes:
# stripe listen --forward-to https://fedow.tibillet.localhost/api/webhook_stripe/ --skip-verify
# stripe listen --forward-to https://tibillet.localhost/api/webhook_stripe/ --skip-verify

# poetry shell
# uv shell
# django-admin makemessages -l fr && django-admin makemessages -l en
# django-admin compilemessages

Expand Down
4 changes: 2 additions & 2 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ USER tibillet
ENV POETRY_NO_INTERACTION=1

## PYTHON
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/home/tibillet/.local/bin:$PATH"

COPY --chown=tibillet:tibillet ./ /DjangoFiles
COPY --chown=tibillet:tibillet ./bashrc /home/tibillet/.bashrc

WORKDIR /DjangoFiles

RUN poetry install
RUN uv sync

CMD ["bash", "/DjangoFiles/start.sh"]

Expand Down
14 changes: 7 additions & 7 deletions flush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ if [ "$DEBUG" = "1" ]; then
createdb $POSTGRES_DB
echo "Database reset complete."

# poetry run python manage.py migrate
poetry run python manage.py migrate_schemas --executor=multiprocessing
poetry run python manage.py install
# uv run manage.py migrate
uv run manage.py migrate_schemas --executor=multiprocessing
uv run manage.py install

# Mode light par défaut (1 tenant, 3 events, 2 adhésions).
# Ajouter --full pour charger toutes les données de démo (5 tenants, initiatives, fédérations).
poetry run python manage.py demo_data_v2
uv run manage.py demo_data_v2

poetry run python manage.py collectstatic --no-input
# poetry run python manage.py create_tenant_superuser --noinput --username root --email root@root.root --schema=public
uv run manage.py collectstatic --no-input
# uv run manage.py create_tenant_superuser --noinput --username root --email root@root.root --schema=public

echo "start dev server : https://"$SUB"."$DOMAIN"/"
poetry run python /DjangoFiles/manage.py runserver 0.0.0.0:8002
uv run /DjangoFiles/manage.py runserver 0.0.0.0:8002
else
echo "DEBUG environment variable is not set"
fi
12 changes: 6 additions & 6 deletions flush_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ for app in "${APPS[@]}"; do
done

echo "=== 3/5 — Generation des nouvelles migrations (1 par app) ==="
poetry run python manage.py makemigrations "${APPS[@]}"
uv run manage.py makemigrations "${APPS[@]}"

echo "=== 4/5 — Migrations + install + demo ==="
poetry run python manage.py migrate_schemas --executor=multiprocessing
poetry run python manage.py install
poetry run python manage.py demo_data_v2
uv run manage.py migrate_schemas --executor=multiprocessing
uv run manage.py install
uv run manage.py demo_data_v2

echo "=== 5/5 — Collectstatic ==="
poetry run python manage.py collectstatic --no-input
uv run manage.py collectstatic --no-input

echo ""
echo "Termine ! Migrations squashees, DB neuve, donnees de demo chargees."
echo "Demarrage du serveur : https://${SUB}.${DOMAIN}/"
poetry run python /DjangoFiles/manage.py runserver 0.0.0.0:8002
uv run /DjangoFiles/manage.py runserver 0.0.0.0:8002
Loading