Skip to content

Conversation

@julianstirling
Copy link
Contributor

@julianstirling julianstirling commented Nov 4, 2025

Adds a mock_all_slots option to create_thing_without_server. This will follow the default specified by thing_slot, so if the default is None no mock is created.

If it is a mapping with no default I think one instance is created, this needs checking in a test is tested.

  • This needs unit tests before merging.

I have targeted it at #195 so the diff is clear. now targets main

Closes #198

@rwb27
Copy link
Collaborator

rwb27 commented Nov 4, 2025

Great :) Glad this works, and it seems like it wasn't too much code to implement it.

I am thinking that it is probably a sensible idea to create a submodule called testing and move this there - along with probably a few other helpful things (like the not-yet-implemented MockServer). Hopefully that makes it easier to find and import.

@barecheck
Copy link

barecheck bot commented Nov 4, 2025

Barecheck - Code coverage report

Total: 94.66%

Your code coverage diff: 0.12% ▴

Uncovered files and lines
FileLines
src/labthings_fastapi/testing.py202

@julianstirling
Copy link
Contributor Author

I understand thing_slots a lot better after implementing this so that is a nice side effect. It is tested.

I think moving it to a testing module is probably a good idea. I like the idea of:

from labthings-fastapi.testing import create_thing_without_server

I think it makes it very clear that this not intended for actual use.

@julianstirling julianstirling marked this pull request as ready for review November 4, 2025 18:33
Copy link
Collaborator

@rwb27 rwb27 left a comment

Choose a reason for hiding this comment

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

This looks great. I've made a couple of suggestions that might be nice, but don't change the way it works meaningfully.

It would be good to move this to a testing module as we discussed, I'm happy for you to do that now, or we can do it later.

@rwb27
Copy link
Collaborator

rwb27 commented Nov 10, 2025

Thinking about review order, I think it might make sense to merge #194/#195 without too many more changes, then we can add the testing module and this code in a (very near) future PR.

@julianstirling
Copy link
Contributor Author

Yeah this is only targeted to #195 so it has a sensible diff. I think aiming it at main once those are merged makes sense

@rwb27 rwb27 force-pushed the docs-tidy-after-dropping-dependencies branch from 0cf53bb to ed2e66f Compare November 15, 2025 09:47
@julianstirling julianstirling changed the base branch from docs-tidy-after-dropping-dependencies to main November 18, 2025 12:31
@julianstirling julianstirling force-pushed the mock_all_slots branch 2 times, most recently from 3ecec6e to 143884d Compare November 18, 2025 13:02
@julianstirling
Copy link
Contributor Author

@rwb27 I just saw you merged #195. This is now rebased again on main since then. And should be ready to go. I had to fix the mock all slots to connect at the end found a bug in how the test class was declared.

Copy link
Collaborator

@rwb27 rwb27 left a comment

Choose a reason for hiding this comment

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

This looks great - thanks for all the rebasing and updates to test code.

I spotted one thing, which is that you defined a constant for a Thing name but then didn't use it. That's trivial enough that I'll make the change and merge it now - no need to bother you with it.

@rwb27 rwb27 merged commit 1cae9de into main Nov 20, 2025
14 checks passed
@rwb27 rwb27 deleted the mock_all_slots branch November 20, 2025 09:52
@rwb27 rwb27 mentioned this pull request Nov 20, 2025
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.

mock_all_slots argument for create_thing_without_serve

3 participants