-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: avoid reflecting back SMOKE_CMONX when changing smart audio #141
Conversation
This value is never reflected back by the UI client and will prevent changing smoke/CO detections if sent
WalkthroughThis update introduces a new method Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/uiprotect/data/devices.py (1)
474-487
: Add a docstring to the method.The method
unifi_dict
is missing a docstring. Adding a docstring will help in understanding the purpose and functionality of the method.def unifi_dict( self, data: dict[str, Any] | None = None, exclude: set[str] | None = None, ) -> dict[str, Any]: """ Manipulates data dictionaries, excluding certain audio types before returning the modified data. Args: data (dict[str, Any] | None): The data dictionary to manipulate. exclude (set[str] | None): The set of keys to exclude from the data dictionary. Returns: dict[str, Any]: The modified data dictionary. """ data = super().unifi_dict(data=data, exclude=exclude) if audio_types := data.get("audioTypes"): # SMOKE_CMONX is not supported for audio types # and should not be sent to the camera data["audioTypes"] = [ t for t in audio_types if t != SmartDetectAudioType.SMOKE_CMONX.value ] return dataTools
GitHub Check: codecov/patch
[warning] 483-483: src/uiprotect/data/devices.py#L483
Added line #L483 was not covered by tests
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/uiprotect/data/devices.py (1 hunks)
Additional context used
GitHub Check: codecov/patch
src/uiprotect/data/devices.py
[warning] 483-483: src/uiprotect/data/devices.py#L483
Added line #L483 was not covered by tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/data/test_camera.py (2 hunks)
Additional comments not posted (11)
tests/data/test_camera.py (11)
20-20
: Import ofSmartDetectAudioType
is appropriate.The import is necessary for the new test function and correctly placed.
1021-1021
: Skip test if camera data is missing.The skip condition ensures that the test only runs if the camera data is available.
1022-1022
: Parameterize the test for both enabled and disabled states.The parameterization ensures that the test covers both enabling and disabling CO detection.
1023-1023
: Mark the test as asynchronous.The
asyncio
marker indicates that the test function is asynchronous.
1024-1026
: Skip test ifcamera_obj
isNone
.The skip condition ensures that the test only runs if the
camera_obj
is available.
1028-1029
: Set necessary feature flags and recording mode.The feature flags and recording mode are set to ensure the test environment is correctly configured.
1031-1038
: Set smart detect settings based on the status.The settings for audio types are correctly adjusted based on the
status
parameter.
1040-1040
: Reset API request mock.Resetting the mock ensures that previous API calls do not interfere with the test.
1042-1044
: Callset_smart_audio_detect_types
with appropriate values.The function call correctly sets the smart audio detect types.
1046-1049
: Assert the correct audio types are set.The assertion ensures that the audio types are correctly set in the
camera_obj
.
1051-1055
: Verify the API request is correctly formed.The API request is checked to ensure it matches the expected format and values.
Description of change
This value is never reflected back by the UI client and will prevent changing smoke/CO detections if sent
Summary by CodeRabbit