-
-
Notifications
You must be signed in to change notification settings - Fork 209
Fix empty data on MapTraceEvent and log input values of rust functions on error #984
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8ee8fe8
Fix empty data on MapTraceEvent
edenhaus cfd2709
Apply suggestions from code review
edenhaus 9b589a9
Add tests for invalid data
edenhaus 2f20d3a
Update deebot_client/map.py
edenhaus a32203a
Log instead
edenhaus bb22b73
Implement code review suggestion
edenhaus 82ad0d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9a349d3
Update src/map.rs
edenhaus 9a4bb5f
Fix invalid codepilot suggestion
edenhaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| """Test rust map module.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from testfixtures import LogCapture | ||
|
|
||
| from deebot_client.rs.map import MapData | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("value", "expected_error", "expected_log"), | ||
| [ | ||
| ( | ||
| "invalid_base64", | ||
| "Invalid symbol 95, offset 7.", | ||
| "Failed to extract trace points: Invalid symbol 95, offset 7.;value:invalid_base64", | ||
| ), | ||
| ( | ||
| "", | ||
| "Invalid 7z compressed data", | ||
| "Failed to extract trace points: Invalid 7z compressed data;value:", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_MapData_add_trace_points_invalid( | ||
| value: str, expected_error: str, expected_log: str | ||
| ) -> None: | ||
| """Test invalid MapData.add_trace_points.""" | ||
| map_data = MapData() | ||
| with pytest.raises(ValueError, match=expected_error), LogCapture() as log: | ||
| map_data.add_trace_points(value) | ||
| log.check_present( | ||
| ( | ||
| "deebot_client.map", | ||
| "ERROR", | ||
| expected_log, | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("index", "base64_data", "expected_error", "expected_log"), | ||
| [ | ||
| ( | ||
| 10000, | ||
| "invalid_base64", | ||
| "Index out of bounds", | ||
| "Index out of bounds; index:10000, base64_data:invalid_base64", | ||
| ), | ||
| ( | ||
| 1, | ||
| "invalid_base64", | ||
| "Invalid symbol 95, offset 7.", | ||
| "Failed to update map piece: Invalid symbol 95, offset 7.; index:1, base64_data:invalid_base64", | ||
| ), | ||
| ( | ||
| 1, | ||
| "", | ||
| "Invalid 7z compressed data", | ||
| "Failed to update map piece: Invalid 7z compressed data; index:1, base64_data:", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_MapData_update_map_piece_invalid( | ||
| index: int, base64_data: str, expected_error: str, expected_log: str | ||
| ) -> None: | ||
| """Test invalid MapData.update_map_piece.""" | ||
| map_data = MapData() | ||
| with pytest.raises(ValueError, match=expected_error), LogCapture() as log: | ||
| map_data.update_map_piece(index, base64_data) | ||
| log.check_present( | ||
| ( | ||
| "deebot_client.map", | ||
| "ERROR", | ||
| expected_log, | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| def test_MapData_map_piece_crc32_indicates_update_invalid() -> None: | ||
| """Test invalid MapData.map_piece_crc32_indicates_update.""" | ||
| map_data = MapData() | ||
| with pytest.raises(ValueError, match="Index out of bounds"), LogCapture() as log: | ||
| map_data.map_piece_crc32_indicates_update(1000, 1) | ||
| log.check_present( | ||
| ( | ||
| "deebot_client.map", | ||
| "ERROR", | ||
| "Index out of bounds; index:1000, crc32:1", | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.