Skip to content

Add a helper function to connect Thing Slots on already-created Things.#344

Merged
rwb27 merged 3 commits into
mainfrom
improve-testing
May 19, 2026
Merged

Add a helper function to connect Thing Slots on already-created Things.#344
rwb27 merged 3 commits into
mainfrom
improve-testing

Conversation

@rwb27
Copy link
Copy Markdown
Collaborator

@rwb27 rwb27 commented May 14, 2026

Trying to mock descriptors is painful, but lt.thing_slot is relatively easy to reconnect with a little boilerplate.

This PR adds a helper function so test code can easily connect Things together without a server.

@barecheck
Copy link
Copy Markdown

barecheck Bot commented May 14, 2026

Barecheck - Code coverage report

Total: 96.88%

Your code coverage diff: 0.01% ▴

Uncovered files and lines
FileLines
src/labthings_fastapi/testing.py140, 257

@julianstirling
Copy link
Copy Markdown
Contributor

I love this. Probably against protocol for it to go in before 0.2 is released?

@rwb27
Copy link
Copy Markdown
Collaborator Author

rwb27 commented May 14, 2026

It's clearly only touching code in testing so I'd have no problem squeezing it in.

OFM v3 check is only failing because of api_prefix which will be fixed there soon enough.

Comment thread src/labthings_fastapi/testing.py
@rwb27 rwb27 force-pushed the improve-testing branch from 5275f02 to 0dadeed Compare May 18, 2026 15:22
This extends `manually_connect_thing_slot` to cope with multiple targets.

Note that the targets must have unique names. There's a check for this, and a test that it works.
I've also added a test that verifies `Mock` objects work, but they require a `spec` to be set.
@rwb27 rwb27 requested a review from julianstirling May 18, 2026 15:44
Copy link
Copy Markdown
Contributor

@julianstirling julianstirling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final suggestion for a docstring update then this looks ready to go.

Comment thread src/labthings_fastapi/testing.py Outdated
@rwb27 rwb27 merged commit 9f8d1f0 into main May 19, 2026
16 checks passed
@rwb27 rwb27 deleted the improve-testing branch May 19, 2026 08:19
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.

2 participants