Add test suite for the Bonsai Viewer Autodesk connector

Introduce pytest coverage for the previously untested connector — rpc,
cache, settings, autodesk (auth + APS client) and connector handlers —
94 tests, runnable via the new `test` optional-dependency extra.

To make HTTP, time and the OAuth redirect testable without a network or
real sockets, add dependency-injection seams to autodesk.py:
AuthSessionService and ApsClient accept an optional httpx transport;
AuthSessionService accepts an injectable clock and callback_waiter; and
_wait_for_callback is extracted to the module-level wait_for_oauth_callback.
All seams default to the previous behaviour.

Remove the APS_CLIENT_ID environment-variable override: the client id now
comes solely from settings.json, collapsing settings.load_client_id and
simplifying the settings dialog.

CI: the build-bonsaiviewer-autodesk workflow gains a `test` job
(Python 3.11 + 3.13) that gates the build matrix.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-05-21 10:23:39 +10:00
parent de7520418b
commit 137a890256
12 changed files with 1452 additions and 80 deletions
@@ -30,8 +30,7 @@ Run
bonsaiviewer-autodesk
The connector launches without configuration. On first run, open the settings
dialog, or set the ``APS_CLIENT_ID`` environment variable, to configure the
Autodesk client ID and OAuth callback port.
dialog to configure the Autodesk client ID and OAuth callback port.
For direct protocol testing, send newline-delimited JSON-RPC 2.0 requests on
standard input:
@@ -51,11 +50,8 @@ exit.
Configuration
-------------
The connector reads the Autodesk client ID from these places, in order:
1. ``APS_CLIENT_ID`` environment variable.
2. ``settings.json`` in the connector config directory, written by the settings
dialog.
The connector reads the Autodesk client ID from ``settings.json`` in the
connector config directory, written by the settings dialog.
The OAuth callback host is always ``localhost``. The callback port defaults to
``8080`` and can be changed in the settings dialog.