-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: parse all the response items from MeijuCloud for get_device_inf #231
Conversation
WalkthroughThe 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 Configuration File (
|
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)
- midealocal/cloud.py (2 hunks)
Additional comments not posted (2)
midealocal/cloud.py (2)
376-393
: Docstring Update: Ensure accuracy and completeness.The updated docstring provides detailed information about the API URL, headers, input, and response structure. Ensure that the docstring accurately reflects the actual API behavior and the response structure.
414-433
: New Attributes: Verify correctness and completeness.The additional attributes in the response processing logic should be verified for correctness. Ensure that all attributes are correctly mapped from the response and that their default values are handled appropriately.
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)
- midealocal/cloud.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- midealocal/cloud.py
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
=======================================
Coverage 37.59% 37.59%
=======================================
Files 84 84
Lines 7451 7451
=======================================
Hits 2801 2801
Misses 4650 4650 ☔ View full report in Codecov by Sentry. |
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.
Please improve tests to check the parse process
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)
- midealocal/cloud.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- midealocal/cloud.py
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
Outside diff range, codebase verification and nitpick comments (1)
tests/responses/meijucloud_get_device_info_alt.json (1)
12-32
: Ensure consistency in field naming conventions.The fields added to the JSON object are generally consistent, but consider the following:
- Use snake_case for consistency with other fields.
- Ensure that the field names are descriptive and relevant.
For example,
activeStatus
should beactive_status
, andwifiVersion
should bewifi_version
.- "activeStatus": 1, - "wifiVersion": "059009012205", + "active_status": 1, + "wifi_version": "059009012205",
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- midealocal/cloud.py (2 hunks)
- tests/cloud_test.py (1 hunks)
- tests/responses/meijucloud_get_device_info_alt.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- midealocal/cloud.py
Additional comments not posted (1)
tests/cloud_test.py (1)
307-327
: LGTM! Ensure all new fields are covered in tests.The added assertions are correct and relevant. They ensure that the
device
object has the expected attributes and values.However, verify that all new fields added to the JSON object are covered in the tests.
Verification successful
All new fields are covered in the tests.
The added assertions in the test file thoroughly cover the new fields in the
device
object.
des
active_status
active_time
master_id
wifi_version
enterprise
is_other_equipment
attrs
room_name
bt_mac
bt_token
hotspot_name
is_bluetooth
bind_type
ability
name_changed
template_of_tsl
shadow_level
smart_product_id
brand
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all new fields in the JSON object are covered in the tests. # Test: Search for all assertions in the test file. Expect: All new fields are covered. rg --type python -A 5 $'assert device.get('Length of output: 131
Script:
#!/bin/bash # Description: Verify all new fields in the JSON object are covered in the tests. # Test: Search for all assertions in the test file. Expect: All new fields are covered. rg --type python -A 5 'assert device.get('Length of output: 131
Script:
#!/bin/bash # Description: Verify all new fields in the JSON object are covered in the tests. # Test: Search for all assertions in the test file. Expect: All new fields are covered. rg --type python 'assert device.get'Length of output: 69
Script:
#!/bin/bash # Description: Verify all new fields in the JSON object are covered in the tests. # Test: Search for all assertions in the test file. Expect: All new fields are covered. rg --glob '*.py' 'assert device.get'Length of output: 3588
thanks for your review comments, add test done, please help to review and check the testcase info. |
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)
- midealocal/cloud.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- midealocal/cloud.py
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 (3)
- midealocal/cloud.py (2 hunks)
- tests/cloud_test.py (1 hunks)
- tests/responses/meijucloud_get_device_info_alt.json (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- midealocal/cloud.py
- tests/cloud_test.py
- tests/responses/meijucloud_get_device_info_alt.json
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.
LGTM
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
Outside diff range, codebase verification and nitpick comments (1)
midealocal/cloud.py (1)
438-456
: Improve docstring formatting and clarity.The docstring provides detailed information about the API interaction, but it can be formatted for better readability and clarity.
- """Get device information. - - API url: https://mp-prod.smartmidea.net/mas/v5/app/proxy?alias=/v1/appliance/info/get - header: - input: {'applianceCode': 21000***830**18, - 'reqId': 'b11bb9083be6d77906fe1c9f019cdea0', 'stamp': '20240710092728'} - response: b'{"code":0,"msg":null,"data":{"id":null, - "applianceCode":21000***830**18, - "sn":"7105f17f36a6afcce272f8053e2be60fd74b1a4baca120afaad83011bb50e8d5f3678bf88e32ea11885394e1a32c9c0e", - "onlineStatus":1,"type":"0xDB","modelNumber":"12877", - "name":"device_name_bytearray", - "des":null,"activeStatus":1,"activeTime":"2024-06-12 10:45:45", - "masterId":null,"wifiVersion":"059009012205","enterprise":"0000", - "isOtherEquipment":null,"attrs":null,"roomName":null, - "btMac":"54B8740FA801","btToken":null,"hotspotName":null, - "isBluetooth":0,"bindType":null,"ability":null,"nameChanged":null, - "sn8":"38127874","supportWot":false,"templateOfTSL":null, - "shadowLevel":null,"smartProductId":10004256,"brand":null}}' - """ + """ + Get device information. + + API URL: https://mp-prod.smartmidea.net/mas/v5/app/proxy?alias=/v1/appliance/info/get + + Header: + - content-type: application/json; charset=utf-8 + - secretVersion: 1 + - sign: <generated_signature> + - random: <timestamp> + - uid: <user_id> (if available) + - accessToken: <access_token> (if available) + + Input: + { + 'applianceCode': 21000***830**18, + 'reqId': 'b11bb9083be6d77906fe1c9f019cdea0', + 'stamp': '20240710092728' + } + + Response: + { + "code": 0, + "msg": null, + "data": { + "id": null, + "applianceCode": 21000***830**18, + "sn": "7105f17f36a6afcce272f8053e2be60fd74b1a4baca120afaad83011bb50e8d5f3678bf88e32ea11885394e1a32c9c0e", + "onlineStatus": 1, + "type": "0xDB", + "modelNumber": "12877", + "name": "device_name_bytearray", + "des": null, + "activeStatus": 1, + "activeTime": "2024-06-12 10:45:45", + "masterId": null, + "wifiVersion": "059009012205", + "enterprise": "0000", + "isOtherEquipment": null, + "attrs": null, + "roomName": null, + "btMac": "54B8740FA801", + "btToken": null, + "hotspotName": null, + "isBluetooth": 0, + "bindType": null, + "ability": null, + "nameChanged": null, + "sn8": "38127874", + "supportWot": false, + "templateOfTSL": null, + "shadowLevel": null, + "smartProductId": 10004256, + "brand": null + } + } + """
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- midealocal/cloud.py (2 hunks)
Additional comments not posted (1)
midealocal/cloud.py (1)
476-496
: Ensure proper handling of new fields in the response dictionary.The new fields added to the response dictionary enhance the functionality. Ensure that these fields are correctly handled and validated in the downstream code.
Verification successful
The new fields in the response dictionary are correctly handled and validated in the downstream code.
- The fields are used in the
midealocal/cloud.py
file.- The fields are also validated in the
tests/cloud_test.py
file.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new fields in the response dictionary are correctly handled in the downstream code. # Test: Search for the usage of the new fields. Expect: Proper handling and validation of these fields. rg --type python -A 5 $'des|active_status|active_time|master_id|wifi_version|enterprise|is_other_equipment|attrs|room_name|bt_mac|bt_token|hotspot_name|is_bluetooth|bind_type|ability|name_changed|support_wot|template_of_tsl|shadow_level|smart_product_id|brand'Length of output: 292
Script:
#!/bin/bash # Description: Verify that the new fields in the response dictionary are correctly handled in the downstream code. # Test: Search for the usage of the new fields. Expect: Proper handling and validation of these fields. rg -t py -A 5 'des|active_status|active_time|master_id|wifi_version|enterprise|is_other_equipment|attrs|room_name|bt_mac|bt_token|hotspot_name|is_bluetooth|bind_type|ability|name_changed|support_wot|template_of_tsl|shadow_level|smart_product_id|brand'Length of output: 44128
@chemelli74 @rokam in addition, these response info is json format from cloud server, so all the types should be json types, and NOT python types. for example, json null vs python none. thanks. |
It's ok for me. |
If you guys both think that's fine, go ahead |
thanks. |
🤖 I have created a release *beep* *boop* --- ## [2.6.0](v2.5.0...v2.6.0) (2024-08-02) ### Features * parse all the response items from MeijuCloud for get_device_inf ([#231](#231)) ([1976eb6](1976eb6)) ### Bug Fixes * **cli:** authenticate to get keys ([#256](#256)) ([a017e7a](a017e7a)) * tank is always seen as full ([#255](#255)) ([3524405](3524405)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Summary by CodeRabbit
New Features
Documentation
Tests