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

Add tests for EigerHandler and EigerConfigHandler #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jsouter
Copy link
Collaborator

@jsouter jsouter commented Nov 15, 2024

Closes (#45)

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.69%. Comparing base (3e1482b) to head (2d7bba0).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
+ Coverage   72.20%   81.69%   +9.49%     
==========================================
  Files           4        4              
  Lines         295      295              
==========================================
+ Hits          213      241      +28     
+ Misses         82       54      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@GDYendell GDYendell left a comment

Choose a reason for hiding this comment

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

Just a few comments.

I think it might be a good idea to intentionally strip down the mock connection here to what we actually use. Or maybe just a MagicMock with specific responses in each test. We do have the system tests for running the introspection against the tickit sim to test the full api.

tests/test_controller.py Outdated Show resolved Hide resolved
tests/test_controller.py Outdated Show resolved Hide resolved
assert top_controller.stale_parameters.get()

# need to update again to make detector controller update its
# stale parameter attribute
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually a problem that we will need to figure out.

tests/test_controller.py Outdated Show resolved Hide resolved
# eiger API does not return a list of updated parameters when we set status keys
# so _parameter_updates set to default case where we only update the key we changed
assert subsystem_controller._parameter_updates == {"humidity"}
# humidity is really read-only but given here for demonstration
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use a writable parameter for this just to avoid any confusion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need to check if any of the parameters handled by EigerHandler actually are rw, but will do

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All parameters with the mode status are read only (see tests/system/parameters.json) - so maybe we should move EigerHandler.update to EigerConfigHandler and make attributes with EigerHandlers read only

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean move put to EigerConfigHandler? I guess that would make sense, but I don't think this is a real issue - attr.sender should fail because humidity should be an AttrR. However, in the test for some reason (in the debugger) humidity is an AttrRW. In fact all of the controllers attributes are AttrRW. Is there something broken in the mock connection causing that?

Copy link
Collaborator Author

@jsouter jsouter Nov 18, 2024

Choose a reason for hiding this comment

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

Yes, every parameter (besides <subsystem>/api/1.8.0/<mode>/keys) just gets a dummy response at the moment

    else:
            # dummy response
            return {"access_mode": "rw", "value": 0.0, "value_type": "float"}

Copy link
Contributor

@GDYendell GDYendell Nov 22, 2024

Choose a reason for hiding this comment

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

Could you try out removing the mock_connection in one of the tests and instead just pass a MagicMock as the controller connection with return_value set for the things that will be called? It doesn't have to have the full api, just pick a few parameters from the API to demonstrate the possible code branches.

@jsouter jsouter linked an issue Nov 21, 2024 that may be closed by this pull request
remove redundant EigerHandler put test, fix test names
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.

Add tests for update task / handlers and stale parameters logic
2 participants