Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ad standard det tests #592

Merged
merged 7 commits into from
Sep 21, 2024

Conversation

jwlodek
Copy link
Member

@jwlodek jwlodek commented Sep 19, 2024

Significantly simplifies tests for ADPilatus and ADSimDetector to use ad_standard_det_factory fixture. Moves some of the mock callback logic to the fixture to simplify other tests as well.

Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

Looks good, nice way of simplifying: is this intended to close #262 or is it just a step in that direction?

There's a couple of type-checking bits that might be useful sanity checks [PathProvider is Callable[[str | None], Path]; ad_standard_det_factory is a Callable[[type[T], int], T], but I think the Pytest Fixtures are making is clear what's being passed: just if we want to strict pyright this module I think they'll need the hints?

set_mock_value(test_adstandard_det.hdf.file_path_exists, True)
set_mock_value(
test_adstandard_det.hdf.full_file_name,
f"{value}/{static_path_provider._filename_provider()}.h5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"{value}/{static_path_provider._filename_provider()}.h5",
f"{value}/{static_path_provider._filename_provider(test_adstandard_det.name)}.h5",

nit: if we ever start using the value of the device name in the static_path_provider

@@ -110,7 +97,7 @@ async def _trigger(


async def test_hints_from_hdf_writer(test_adpilatus: adpilatus.PilatusDetector):
assert test_adpilatus.hints == {"fields": ["test_adpilatus"]}
assert test_adpilatus.hints == {"fields": ["test_adpilatus1"]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert test_adpilatus.hints == {"fields": ["test_adpilatus1"]}
assert test_adpilatus.hints == {"fields": [test_adpilatus.name]}

nit: I think the important check here is that the hinted field for the hdfwriter comes from the device name

@jwlodek
Copy link
Member Author

jwlodek commented Sep 20, 2024

Looks good, nice way of simplifying: is this intended to close #262 or is it just a step in that direction?

Mostly just a step in that direction - I think the tests can be further simplified by just paramterizing over the different standard detector classes, leaving just the tests for the individual controllers. But I'll leave that for another PR since this one is already fairly broad.

@jwlodek jwlodek merged commit e7cef5b into bluesky:main Sep 21, 2024
11 checks passed
tomtrafford pushed a commit that referenced this pull request Oct 8, 2024
* Refactor ADPilatus tests to use the ad_standard_det_factory

* Add default signals for sim detector config

* Fix type annotation

* Overhaul sim detector tests to use ad standard det factory, improve factory with mock put callback

* Fix tests for remaining detectors to account for new changes to factory fixture

* Make sure to include config_sigs passed to init

* Add suggestions from review
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.

3 participants