Skip to content

test(integration): MySQL 8 + Postgres 16 con Testcontainers#9

Merged
ShibaRoPinoo merged 1 commit into
feature/fase-2-postgresfrom
feature/integration-tests
May 18, 2026
Merged

test(integration): MySQL 8 + Postgres 16 con Testcontainers#9
ShibaRoPinoo merged 1 commit into
feature/fase-2-postgresfrom
feature/integration-tests

Conversation

@ShibaRoPinoo
Copy link
Copy Markdown
Owner

Resumen

Cierra la cadena de la v2 verificando contra MySQL 8 y Postgres 16 reales con Testcontainers. 7/7 verdes localmente (~39s end-to-end).

Cobertura por motor

MySQL (`tests/integration/test_mysql_e2e.py`)

  • CREATE TABLE con AUTO_INCREMENT
  • INSERT/SELECT/UPDATE/DELETE, count, order_by
  • upsert con `ON DUPLICATE KEY UPDATE`
  • Rollback de transacción al lanzar excepción
  • ORM end-to-end: `Model.save/find/where`

Postgres (`tests/integration/test_postgres_e2e.py`)

  • CRUD análogo con quoting de doble comilla
  • upsert con `ON CONFLICT DO UPDATE`
  • PK `GENERATED ALWAYS AS IDENTITY` (verifica numeración 1, 2)

Mecánica

  • Marker `@pytest.mark.integration` añadido a `pyproject.toml`.
  • Pytest por defecto deselecciona el marker (`-m 'not integration'`) → `pytest -q` sigue siendo rápido y sin Docker.
  • Fixtures de scope session para reutilizar contenedores.
  • `SHIBA_SKIP_INTEGRATION=1` permite saltarlos en entornos sin Docker.

CI

`.github/workflows/ci.yml` ahora tiene dos jobs:

  • `unit` (matriz 3.10–3.13) — bloqueante.
  • `integration` (3.12, ubuntu-latest con Docker built-in) — corre después de unit.

Test plan

  • `pytest -q` (default unit) → 114 passed, 7 deselected
  • `pytest -m integration` local → 7 passed contra contenedores reales (39s)
  • `ruff` y `mypy --strict` limpios
  • CI verde en GitHub Actions

Apilado sobre #8. Mergear después de #5, #6, #7, #8.

🤖 Generated with Claude Code

Cierra la cadena de la v2 verificando que el query builder, el upsert,
las transacciones y el ORM funcionan contra motores reales.

Estructura
- `tests/integration/` con marker `@pytest.mark.integration`. Por
  defecto los unit tests deseleccionan este marker (configurado en
  `pyproject.toml` con `-m 'not integration'`).
- Conftest que arranca los contenedores una vez por sesión y entrega
  una `ShibaConnection` lista por test. `SHIBA_SKIP_INTEGRATION=1`
  los salta sin Docker.

Cobertura por dialecto
- MySQL: CREATE TABLE con AUTO_INCREMENT, INSERT/SELECT/UPDATE/DELETE,
  count + order_by, upsert (`ON DUPLICATE KEY UPDATE`), rollback de
  transacción con excepción, ORM end-to-end con `Model.save/find/where`.
- Postgres: lo mismo más PK `GENERATED ALWAYS AS IDENTITY` (verifica
  numeración 1, 2) y upsert (`ON CONFLICT DO UPDATE`).

Dependencias
- `testcontainers[mysql,postgres]>=4.7` añadido a `[dev]`.

CI
- Workflow extendido con dos jobs: `unit` (matriz 3.10–3.13) que sigue
  bloqueando merges, e `integration` (3.12) que arranca contenedores
  reales después de unit. Ubuntu-latest ya viene con Docker.

Estado
- 114 unit (deseleccionados los 7 integration por default).
- 7 integration verdes localmente (39s end-to-end).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ShibaRoPinoo ShibaRoPinoo merged commit 844213b into feature/fase-2-postgres May 18, 2026
1 of 5 checks passed
ShibaRoPinoo added a commit that referenced this pull request May 18, 2026
Consolida en un solo commit el trabajo de los PRs #5#9 (cuyas ramas
quedaron divergentes tras varios force-pushes para fix de CI). El detalle
por fase vive en los PRs cerrados.

Fase 0 — Seguridad y estructura
- Paquete `shiba/` modular con core/ agnóstico y dialects/.
- SQL injection cerrada: valores parametrizados, identificadores
  validados y citados por dialecto.
- Catálogo `SHIBA-XYZW` de error codes con mapper desde drivers.
- Excepciones tipadas, transacciones explícitas, context manager.
- `shibamysql/` shim deprecated.
- Tooling: pyproject.toml, ruff, mypy --strict, pytest, CI.

Fase 1 — Query builder rico
- `or_where`, `where_in/not_in/null/not_null/like/between`,
  `where_group(callback)`, `where_json(col, path, value)`.
- `group_by`, `having`, `find`, `exists`, `pluck`, agregados.
- `paginate`, `chunk`, `iterate`.
- `upsert(data, on=[...])`, `truncate`, `raw` escape hatch.

Fase 1.5 — ORM híbrido tipado
- `Model` con metaclass que lee anotaciones por MRO con
  `inspect.get_annotations(eval_str=True)`.
- 12 subclases de `Field` (PrimaryKey, String, Json, DateTime,
  DecimalField, Enum, ForeignKey, ...) e inferencia automática.
- `ModelQuery[T]` hidrata filas a instancias.
- Conexión global (`set_default_connection`) o por clase (`__db__`).

Fase 2 — PostgreSQL
- Dialect con doble comilla, `JSONB`, `BYTEA`, `TIMESTAMP`,
  `GENERATED ALWAYS AS IDENTITY`, `ON CONFLICT DO UPDATE`.
- Driver psycopg3 con import perezoso (dep opcional).
- `shiba.connect("mysql://...")`/`postgres://...` factory.

Fase 4 — Tests de integración
- 7 tests sobre MySQL 8 y Postgres 16 con Testcontainers,
  marker `integration`, job CI separado.

Stats
- 114 unit tests + 7 integration verdes (39s end-to-end).
- ruff y mypy --strict limpios sobre 25 archivos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ShibaRoPinoo added a commit that referenced this pull request May 18, 2026
Consolida en un solo commit el trabajo de los PRs #5#9 (cuyas ramas
quedaron divergentes tras varios force-pushes para fix de CI). El detalle
por fase vive en los PRs cerrados.

Fase 0 — Seguridad y estructura
- Paquete `shiba/` modular con core/ agnóstico y dialects/.
- SQL injection cerrada: valores parametrizados, identificadores
  validados y citados por dialecto.
- Catálogo `SHIBA-XYZW` de error codes con mapper desde drivers.
- Excepciones tipadas, transacciones explícitas, context manager.
- `shibamysql/` shim deprecated.
- Tooling: pyproject.toml, ruff, mypy --strict, pytest, CI.

Fase 1 — Query builder rico
- `or_where`, `where_in/not_in/null/not_null/like/between`,
  `where_group(callback)`, `where_json(col, path, value)`.
- `group_by`, `having`, `find`, `exists`, `pluck`, agregados.
- `paginate`, `chunk`, `iterate`.
- `upsert(data, on=[...])`, `truncate`, `raw` escape hatch.

Fase 1.5 — ORM híbrido tipado
- `Model` con metaclass que lee anotaciones por MRO con
  `inspect.get_annotations(eval_str=True)`.
- 12 subclases de `Field` (PrimaryKey, String, Json, DateTime,
  DecimalField, Enum, ForeignKey, ...) e inferencia automática.
- `ModelQuery[T]` hidrata filas a instancias.
- Conexión global (`set_default_connection`) o por clase (`__db__`).

Fase 2 — PostgreSQL
- Dialect con doble comilla, `JSONB`, `BYTEA`, `TIMESTAMP`,
  `GENERATED ALWAYS AS IDENTITY`, `ON CONFLICT DO UPDATE`.
- Driver psycopg3 con import perezoso (dep opcional).
- `shiba.connect("mysql://...")`/`postgres://...` factory.

Fase 4 — Tests de integración
- 7 tests sobre MySQL 8 y Postgres 16 con Testcontainers,
  marker `integration`, job CI separado.

Stats
- 114 unit tests + 7 integration verdes (39s end-to-end).
- ruff y mypy --strict limpios sobre 25 archivos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant