Implement a JSON Review UI that allow user to perform actions on json files
Review Request #9515 — Created Jan. 21, 2018 and updated
Json files is handled as an uneditble attachments in the current
version.
I implemented a new classJSONReviewUI
that
enhence Review board's ability to process JSON file.New features include:
- Rendering JSON in an easy-to-read format.
- Allowing the user to comment on the prettified file based on
line numbers. - Auto-sorting of output keys.
- Allow user to compare the changes of files in diffs
- A thumbnail that render in the easy-to-read format, too.
Ran unit tests.
Tested the development environment with:
- Properly formatted JSON files.
- JSON files with long lines.
- Minified JSON files.
- Highly-nested JSON files.
Description | From | Last Updated |
---|---|---|
Can you wrap your description at 72 characters and format it as markdown? We can do stuff like: New features … |
brennie | |
As for your testing done, how about: Ran unit tests. Tested the development environment with: - Properly formatted JSON files. … |
brennie | |
This needs some unit tests ensuring that (at a minimum): the JSON UI is used for JSON files prettified JSON … |
brennie | |
How about JSONReviewUI ? It's a little shorter and gets the same point across. |
brennie | |
All methods should have docstring documenting what they do. Check out this guide for our docstring requirements. |
brennie | |
Do you need to explicitly open the file when use already use the with keyword? or do something like with … |
FL floriecai | |
Is the indent always going to be 4? Maybe keep as a constant? |
FL floriecai | |
Just out of curiosity, what does the _ do before the string? |
FL floriecai | |
Typo: hekper -> helper |
FL floriecai | |
Not sure if this will be a problem - but does os.path.join correctly change slashes based on the appropriate os? |
FL floriecai | |
Keep the function names consistent, so: test_wrong_formatted_JSON |
FL floriecai | |
inconsistent function naming: test_prettified_JSON |
FL floriecai | |
Instead of adding this to the text mimetype, I think we need a new JSONMimetype class that can run the … |
david | |
Can you add a module docstring at the top of this file? |
david | |
This is kind of a weird docstring, and doesn't explain what the return (yield) type is. How about: """Render the … |
david | |
Let's just revert the changes to this file. We should clean up docstrings here (eventually), but it shouldn't be part … |
david | |
Standard library imports should go in a section above 3rd-party imports. |
david | |
This docstring isn't in the proper format. How about just """Set up state for ImageReviewUI tests.""" |
david | |
This should probably be called JSONReviewUITests to match the naming elsewhere. |
david | |
No blank line here. |
david | |
Blank line between these. This should also say "JSONReviewUI" to match the name of the class. |
david | |
Docstring summaries need to start with capital letters and end in periods. This also needs Args and Returns sections to … |
david | |
We should put test data in a directory called "testdata", not "testJsonData". Right now we also have a weird mix … |
david | |
Blank line above this. |
david | |
file is a reserved word in Python. Let's change this name. |
david | |
It's kind of weird to have this set self.attachment as a side effect and then return the uploaded file object … |
david | |
There's an extra space at the end of this docstring. Test docstrings should also always start with "Testing" and include … |
david | |
Just initializing the review UI won't actually run the render function. I think you forgot the code to test get_rendered_lines() |
david | |
Same comment about docstrings. How about: Testing JSONReviewUI render with invalid JSON |
david | |
Can we rename all of these test files to be lower-case with hyphens instead of camelCase or CamelCase? |
david | |
u prefixes on strings aren't necessary since we import unicode_literals. You also don't need to use + to concatenate multiple … |
david | |
Format is wrong here and there's some spelling errors. How about: Testing JSONReviewUI indenting and sorting |
david | |
F401 'django.utils.translation.ugettext as _' imported but unused |
reviewbot | |
Undo this. ) should be on the previous line. |
david | |
These should be grouped with the other 3rd-party imports (back where they were) |
david | |
Since we're inheriting from TextMimetype we don't need to redefine these. |
david | |
typo: beautifed -> beautified |
david | |
TextMimetype isn't used |
david | |
Can you keep these names in alphabetical order? |
david | |
Json -> JSON |
david | |
This should fit on one line. |
david | |
Keep in alphabetical order |
david | |
Keep in alphabetical order. |
david | |
Instead of using logging.error with exc_info=True, you can use logging.exception. |
david | |
Docstring isn't in the proper format. Let's just avoid making any changes to this file--if we want to clean up … |
david | |
Test docstrings shouldn't end in periods (since the test runner will add "...") |
david | |
Test docstrings shouldn't end in periods (since the test runner will add "...") |
david | |
Since this is an internal helper, let's add a leading underscore: _get_json_file |
david | |
This needs to be the fully-qualified module path of the type: reviewboard.attachments.models.FileAttachment |
david | |
The directory should be called testdata, not testData. |
david | |
You're still storing this in self.attachment and then calling this method as if it doesn't have a return value. This … |
david | |
Test docstrings shouldn't end in periods (since the test runner will add "...") |
david | |
No blank line here. |
david | |
Don't we want to assert something in here? |
david | |
Test docstrings shouldn't end in periods (since the test runner will add "...") |
david | |
No blank line here. |
david | |
Test docstrings shouldn't end in periods (since the test runner will add "...") |
david | |
No blank line here. |
david | |
We should still wrap by putting everything in parens instead of using the continuation character. |
david | |
This should probably be the same as the class docstring ("A review UI for JSON files") |
david | |
"Review UI" -> "review UI" |
david | |
The line break here is ugly. Please combine these. |
david | |
Blank line isn't necessary here. |
david | |
Blank line isn't necessary here. |
david | |
json file -> JSON file |
david | |
Should list a type in parens: filename (unicode): |
david | |
Indent this 4 more spaces. |
david | |
This is an extra call to get_rendered_lines which is not needed. |
david | |
It might be nicer to hard-code the "correct" result rather than running it through the review UI. Right now if … |
david | |
We wrap long strings with the space characters and the end of previous lines instead of the start of the … |
david | |
Same here--let's hard-code the correct output instead of running it through the review UI. |
david |
- Summary:
-
Better review for JSON filesImplement a JSON Review UI that allow user to perform actions on json files
- Description:
-
~ Implemented a new class
TextBasedJSONReviewUI
that~ enhence Review board's review for JSON file. ~ Json files is handled as an uneditble attachments in the current version.
~ I implemented a new class TextBasedJSONReviewUI
that+ enhence Review board's ability to process JSON file. New features include:
rendering the JSON file in a easy-to-read format allow user to comment on the file based on line auto sorting keys in objects allow user to compare the changes of files in diffs
-
-
Can you wrap your description at 72 characters and format it as markdown?
We can do stuff like:
New features include: - Rendering JSON in an easy-to-read format. - Allowing the user to comment on the prettified file based on line numbers. - Auto-sorting of output keys.
etc.
Which will render as a list.
-
As for your testing done, how about:
Ran unit tests. Tested the development environment with: - Properly formatted JSON files. - JSON files with long lines. - Minified JSON files. - Highly-nested JSON files.
The coverage percentage is not required.
-
This needs some unit tests ensuring that (at a minimum):
- the JSON UI is used for JSON files
- prettified JSON files are ordered consistently between viewings
- output is actually prettified
-
-
All methods should have docstring documenting what they do. Check out this guide for our docstring requirements.
- Description:
-
~ Json files is handled as an uneditble attachments in the current version.
~ Json files is handled as an uneditble attachments in the current
+ version. I implemented a new class TextBasedJSONReviewUI
thatenhence Review board's ability to process JSON file. ~ New features include:
~ rendering the JSON file in a easy-to-read format ~ allow user to comment on the file based on line ~ auto sorting keys in objects ~ allow user to compare the changes of files in diffs ~ ~ ~ New features include:
~ ~ - Rendering JSON in an easy-to-read format.
+ - Allowing the user to comment on the prettified file based on
line numbers.
+ - Auto-sorting of output keys.
+ - Allow user to compare the changes of files in diffs
- Testing Done:
-
~ Manual:
~ Ran unit tests.
- * Tested the dev environment with : - Regular formatted JSON files - JSON file with long array - JSON files that are wrong formatted - Nested JSON files ~ Automated:
~ * Ran unit tests. (coverage 68%) ~ Tested the development environment with:
~ + - Properly formatted JSON files.
+ - JSON files with long lines.
+ - Minified JSON files.
+ - Highly-nested JSON files.
- Diff:
-
Revision 2 (+185 -2)
Checks run (2 succeeded)
- Description:
-
Json files is handled as an uneditble attachments in the current
version. ~ I implemented a new class TextBasedJSONReviewUI
that~ I implemented a new class JSONReviewUI
thatenhence Review board's ability to process JSON file. New features include:
- Rendering JSON in an easy-to-read format.
- Allowing the user to comment on the prettified file based on
line numbers.
- Auto-sorting of output keys.
- Allow user to compare the changes of files in diffs
- Change Summary:
-
fixed the issur that Florie indicated
- Diff:
-
Revision 3 (+184 -2)
Checks run (2 succeeded)
-
-
Instead of adding this to the text mimetype, I think we need a new JSONMimetype class that can run the source through DjbletsJSONEncoder like the JSONReviewUI does.
-
-
This is kind of a weird docstring, and doesn't explain what the return (yield) type is. How about:
"""Render the text. This will render the JSON file in a more readable manner, reindenting the output, sorting keys within dictionaries, and applying syntax highlighting. Yields: unicode: Each line of the rendered output. """
-
Let's just revert the changes to this file. We should clean up docstrings here (eventually), but it shouldn't be part of this change.
-
-
This docstring isn't in the proper format. How about just
"""Set up state for ImageReviewUI tests."""
-
-
-
-
Docstring summaries need to start with capital letters and end in periods. This also needs Args and Returns sections to explain what
file_directory
is and what the return value is.I think
file_directory
should also be called eitherfilename
orjson_file
. Because it's not a directory at all. -
We should put test data in a directory called "testdata", not "testJsonData".
Right now we also have a weird mix of using os.path.join and string concatenation. Everything should be passed in to join and we shouldn't have any directory separators:
file_path = os.path.join( os.path.dirname(__file__), 'testdata', filename)
-
-
-
It's kind of weird to have this set
self.attachment
as a side effect and then return the uploaded file object (which nothing uses). Let's change this to return the attachment instead of storing it inself
. -
There's an extra space at the end of this docstring. Test docstrings should also always start with "Testing" and include full context. How about:
Testing JSONReviewUI rendering nested objects
-
Just initializing the review UI won't actually run the render function. I think you forgot the code to test
get_rendered_lines()
-
-
Can we rename all of these test files to be lower-case with hyphens instead of camelCase or CamelCase?
-
u prefixes on strings aren't necessary since we import
unicode_literals
. You also don't need to use + to concatenate multiple lines (python will concatenate adjacent strings, like C). -
Format is wrong here and there's some spelling errors. How about:
Testing JSONReviewUI indenting and sorting
- Description:
-
Json files is handled as an uneditble attachments in the current
version. I implemented a new class JSONReviewUI
thatenhence Review board's ability to process JSON file. New features include:
- Rendering JSON in an easy-to-read format.
- Allowing the user to comment on the prettified file based on
line numbers.
- Auto-sorting of output keys.
- Allow user to compare the changes of files in diffs
+ - A thumbnail that render in the easy-to-read format, too.
-
-
-
-
-
-
-
-
-
-
-
-
-
Docstring isn't in the proper format. Let's just avoid making any changes to this file--if we want to clean up code, it should be in separate changes.
-
-
-
-
This needs to be the fully-qualified module path of the type:
reviewboard.attachments.models.FileAttachment
-
-
You're still storing this in
self.attachment
and then calling this method as if it doesn't have a return value. This should just be:return form.create()
and then below, in the test methods:
ui = JSONReviewUI(self.review_request, self.get_json_file('filename.json'))
-
-
-
-
-
-
-
- Diff:
-
Revision 6 (+282 -8)
Checks run (2 succeeded)
-
-
-
-
-
-
-
-
-
-
-
-
It might be nicer to hard-code the "correct" result rather than running it through the review UI. Right now if there's some change or bug that affects highlighting or reindenting, it will affect both the original and the "correct" file, making it possibly slip through the test.
-
We wrap long strings with the space characters and the end of previous lines instead of the start of the next.
-
- Diff:
-
Revision 7 (+278 -8)