Skip to content

feat(testing): Testcontainers integration — Docker fixtures + @ServiceConnection wiring (v26.06.31)#56

Merged
ancongui merged 2 commits into
mainfrom
feat/testcontainers
Jun 7, 2026
Merged

feat(testing): Testcontainers integration — Docker fixtures + @ServiceConnection wiring (v26.06.31)#56
ancongui merged 2 commits into
mainfrom
feat/testcontainers

Conversation

@ancongui
Copy link
Copy Markdown
Contributor

@ancongui ancongui commented Jun 7, 2026

Summary

Wave 4 (final) — the Spring Boot @Testcontainers / @ServiceConnection equivalent (pyfly.testing.testcontainers).

  • Container factories (postgres_container, mysql_container, redis_container, mongodb_container, kafka_container) wrapping testcontainers — new optional extra pyfly[testcontainers], lazily imported with a clear install hint.
  • @ServiceConnection-style auto-wiring: pyfly_config_for(container) maps a started container to pyfly config keys (Postgres/MySQL → async pyfly.data.relational.url; Redis → pyfly.cache.redis.url + pyfly.session.redis.url; Mongo → pyfly.data.document.uri; Kafka → pyfly.eda.kafka.bootstrap-servers); pyfly_config(*containers) builds a ready Config.
  • Graceful skip: is_docker_available() + @requires_docker skip integration tests cleanly when Docker / the extra is absent.

Tests

tests/testing/test_testcontainers.py (10): per-type mappings via duck-typed fakes (no Docker), _nest, docker-availability, extra-absent clear error, @requires_docker skip (verified skipping here). Real container startup is exercised by the skip path where Docker exists.

Gates

mypy --strict (614) ✓ · ruff + ruff format ✓ · full suite 3786 passed, 2 skipped.

Bumps v26.06.30 → v26.06.31. Wave 4 complete. Next: Wave 5 (docs + skills/agents).

Andrés Contreras Guillén added 2 commits June 7, 2026 11:36
…Serviceconnection wiring + bump v26.06.31

Wave 4 (final) — Spring @Testcontainers/@Serviceconnection equivalent in
pyfly.testing.testcontainers:
- Container factories (postgres/mysql/redis/mongodb/kafka) wrapping testcontainers
  (new optional extra pyfly[testcontainers]; lazy import + clear install hint).
- pyfly_config_for(container) maps a started container to pyfly config keys
  (Postgres/MySQL->async relational.url, Redis->cache+session redis.url, Mongo->document.uri,
  Kafka->eda.kafka.bootstrap-servers); pyfly_config(*containers) builds a Config.
- is_docker_available() + @requires_docker skip integration tests cleanly when Docker absent.

Tests: tests/testing/test_testcontainers.py (10: mappings via fakes, nesting, docker-availability,
extra-absent error, requires_docker skip). Gates: mypy --strict (614), ruff + format,
full suite 3786 passed (+graceful skip).
CI runs --all-extras (testcontainers installed) on Docker-enabled runners, so the
'extra absent' + 'skips without docker' assumptions failed there. Replace with:
- _load() against a nonexistent submodule -> RuntimeError install hint (works whether or
  not the extra is installed);
- inspect that @requires_docker attaches a skipif mark (works whether or not Docker is up).
Verified passing with testcontainers both absent and installed.
@ancongui ancongui merged commit b3989f3 into main Jun 7, 2026
5 checks passed
@ancongui ancongui deleted the feat/testcontainers branch June 7, 2026 09:42
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