-
Notifications
You must be signed in to change notification settings - Fork 19
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 missing titles #156
Merged
Merged
Add missing titles #156
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8231eda
buddy: Add missing titles for bootloader errors
Tomcus 1679f2f
buddy: Add "Warning" title to all warnings
Tomcus 95f44bc
buddy: Add title to crash detection errors
Tomcus 671a547
buddy: Add title to remaining dialogs
Tomcus 76ef834
buddy: Add title to MMU error
Tomcus c7e4712
test: Add a unit test to verify buddy error codes
Tomcus 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 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,43 @@ | ||
import unittest | ||
import yaml | ||
from typing import List, Dict | ||
|
||
class TestVerifyPruseErrorContentsForBuddy(unittest.TestCase): | ||
def verify_item_in_error(self, error: Dict, item_name: str, can_be_empty:bool = False): | ||
assert item_name in error, f"Missing item {item_name} in error code {error['code']}" | ||
if not can_be_empty: | ||
assert len(error[item_name]) > 0, f"Item {item_name} in error code {error['code']} is empty" | ||
|
||
def verify_non_empty_array_item(self, error: Dict, item_name: str, is_optional: bool = False): | ||
assert item_name in error or is_optional, f"Missing item {item_name} in error code {error['code']}" | ||
if (is_optional and item_name in error) or not is_optional: | ||
assert len(error[item_name]) > 0, f"Empty array item {item_name} defined in error code {error['code']}" | ||
|
||
def test_buddy_errors(self): | ||
errors = [] | ||
with open("./yaml/buddy-error-codes.yaml", "r") as buddy_errors: | ||
errors = yaml.load(buddy_errors, Loader=yaml.Loader)["Errors"] | ||
for error in errors: | ||
assert "code" in error, f"Missing error code code in definition: {error}" | ||
assert error["code"].startswith("XX"), f"Code {error['code']} is missing XX prefix" | ||
self.verify_item_in_error(error, "id") | ||
self.verify_item_in_error(error, "title") | ||
self.verify_item_in_error(error, "text") | ||
self.verify_non_empty_array_item(error, "printers", True) | ||
|
||
|
||
def test_mmu_errors(self): | ||
errors = [] | ||
with open("./yaml/mmu-error-codes.yaml", "r") as mmu_errors: | ||
errors = yaml.load(mmu_errors, Loader=yaml.Loader)["Errors"] | ||
for error in errors: | ||
assert "code" in error, f"Missing error code code in definition: {error}" | ||
assert error["code"].startswith("04"), f"Code {error['code']} is missing 04 prefix" | ||
self.verify_item_in_error(error, "id") | ||
self.verify_item_in_error(error, "title") | ||
self.verify_item_in_error(error, "text") | ||
self.verify_item_in_error(error, "type") | ||
self.verify_non_empty_array_item(error, "action") | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains 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.
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.
Appreciate the unittest 👍