No change is merged without the project owner's review and approval
Contributors open PRs against develop; never push directly to main.
src/pyapiary/
api_connectors/ # HTTP API connectors (Broker subclasses)
dbms_connectors/ # Database connectors
helpers.py # Shared utilities — edit with care
tests/
test_<name>/
test_unit_<name>.py
test_unit_async_<name>.py
test_integration_<name>.py
cassettes/ # VCR cassettes for integration tests
dev_env/ # Local scratch scripts — never imported by the package
Do not create files outside this structure without an explicit request.
- Never add a package to
pyproject.tomloruv.lock/poetry.lockunless the contributor's task explicitly requires a new dependency and the maintainer has approved it. - Never remove a package from
pyproject.tomleven if it appears unused in the files you're editing. Removals require explicit sign-off. - Package management uses Poetry. Run
poetry install --all-extrasto sync; do not usepip installdirectly.
Every connector follows the same structure. Study an existing one (e.g.,
flashpoint.py) before writing a new one.
- Sync class inherits from
Broker; async class inherits fromAsyncBroker. - Decorate every public method with
@log_method_call. - Pull credentials from the constructor arg first, then
self.env_config.get("KEY"). - Raise
ValueErrorwith the env var name when a required credential is missing. - Name the file after the service in lowercase (e.g.,
acme.py).
- Follow the same sync/async pairing and credential pattern.
- Provide both a sync and async class in the same file when the service
supports it (see
mongo.py/mongo_async.pyfor the split-file variant).
All new public methods and new connectors must ship with tests. No exceptions.
Each connector gets its own subdirectory under src/pyapiary/tests/:
tests/test_<name>/
test_unit_<name>.py # sync class, mocked with unittest.mock
test_unit_async_<name>.py # async class, mocked with AsyncMock + @pytest.mark.asyncio
test_integration_<name>.py # real HTTP via VCR cassette
cassettes/ # .yaml cassette files recorded once, committed
Unit (sync & async):
__init__with explicit credential arg__init__picking up credential from env var (@patch.dict("os.environ", ...))__init__raisingValueErrorwhen credential is absent- One test per public method, mocking the underlying HTTP call
Integration:
- At least one method per connector exercised against a recorded VCR cassette.
- Cassette files are committed. Never record against a live API in CI.
poetry run pytest --ignore=dev_envCI runs this exact command. All tests must pass before opening a PR.
- Do not add abstractions, base classes, or helpers that have only one consumer. Put the logic in the connector.
- Do not add comments that restate what the code does. A short docstring on a class or method is fine; inline narrative comments are not.
- Do not introduce new test frameworks, fixtures libraries, or pytest plugins.
The existing stack is
pytest,pytest-mock,pytest-asyncio, andvcrpy. - Do not touch
ci.ymlorrelease.ymlwithout explicit instruction. - Do not modify
helpers.pyas a side effect of connector work. - Do not leave
dev_env/scripts in a broken state; that directory is for local experimentation only and is ignored by CI.
Before opening a PR, verify:
-
poetry run pytest --ignore=dev_envpasses locally - New connector or method has all three test files (unit sync, unit async, integration)
- No packages added or removed from
pyproject.toml - No files created outside the established directory structure
- PR targets
develop, notmain