Add testing framework for ReviewBot tools
Review Request #10288 — Created Oct. 27, 2018 and discarded
Previously, we did not have tests for tools in Review Bot.
This change adds a framework for testing the output parsing logic of
the Review Bot tool classes. Additionally, some sample unit tests have
been added to demonstrate how I envision this framework being used.
Successfuly ran the unit tests (
./tests/runtests.py
).
Description | From | Last Updated |
---|---|---|
Description should be wrapped at 72 characters? |
ilaw | |
Double quotes are used in some places where it should be single quotes |
ilaw | |
"Review Bot" is the modern titling for the product, so the description should be reflective of that. (The repository has … |
chipx86 | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
E225 missing whitespace around operator |
reviewbot | |
E501 line too long (84 > 79 characters) |
reviewbot | |
E501 line too long (84 > 79 characters) |
reviewbot | |
Single quotes? |
ilaw | |
Review Bot instead of reviewbot |
ilaw | |
E501 line too long (84 > 79 characters) |
reviewbot | |
E501 line too long (84 > 79 characters) |
reviewbot | |
This doesn't appear related to the change. |
chipx86 | |
nose is a third-party module, so it should be part of its own import group. |
chipx86 | |
First line of the file should be a docstring summary of the file. |
chipx86 | |
unittest is part of Python, so it should be in its own import group (which would come before mock's). |
chipx86 | |
/ isn't a safe assumption for path separators. Instead, whenever we need a path, we should build it with os.path.join |
chipx86 | |
There's too much happening in this file and class. It'll get unwieldy as we go. What we should do is … |
chipx86 | |
"Review Bot" Missing a period. |
chipx86 | |
The space at the beginning of the summary must be removed. |
chipx86 | |
These must be valid Python types, so: list of dict |
chipx86 | |
This doesn't quite match the way we do argument summaries. Something more like: Each dictionary represents a file in the … |
chipx86 | |
It would be really nice not to use Mock. While mocks can be useful, they can also make it increasingly … |
chipx86 | |
Blank line between statements and blocks. |
chipx86 | |
Blank line between statements and blocks. |
chipx86 | |
Blank line between blocks. |
chipx86 | |
Blank line between statements and blocks. |
chipx86 | |
Blank line between statements and blocks. |
chipx86 | |
Docstring summaries must be confined to one line. This can be: Assert that comments in a review match expected comments. |
chipx86 | |
dict |
chipx86 | |
For the tuples, turn them into literals, like: ... and value is a tuple in the form of ``(comment, line, … |
chipx86 | |
Needs to be bool, optional, since the argument doesn't have to be provided. The content is also indented too far. |
chipx86 | |
When we get rid of mocks, and use kgb, we'll be able to get rid of the if and just … |
chipx86 | |
Must be one line. |
chipx86 | |
Make sure blank lines, indentation, types, and formatting are correct. Also, don't forget the , optional optional arguments. Types that … |
chipx86 | |
unicode, not string. |
chipx86 | |
Please use kgb instead of mocks here. Also, these are very specific to flake8, which means this function is useless … |
chipx86 | |
This must exist in a test case (and file) specific to this tool. |
chipx86 | |
The format for testing docstrings should be in the form of: """Testing <toolname> with <condition>""" This helps keep the output … |
chipx86 | |
This must be in a Flake8-specific test case and file. |
chipx86 | |
E501 line too long (107 > 79 characters) |
reviewbot | |
E501 line too long (107 > 79 characters) |
reviewbot | |
E501 line too long (106 > 79 characters) |
reviewbot | |
E501 line too long (93 > 79 characters) |
reviewbot | |
E501 line too long (93 > 79 characters) |
reviewbot |
- Description:
-
Previously, we did not have tests for tools in ReviewBot.
~ This change adds a framework for testing the output parsing logic of the ReviewBot tool classes. Additionally, two sample unit tests have been added to demonstrate how I envision this framework being used.
~ This change adds a framework for testing the output parsing logic of
+ the ReviewBot tool classes. Additionally, two sample unit tests have + been added to demonstrate how I envision this framework being used. - Commit:
-
81e278667372b8a2a6641a639e1a99893d803dbbf18b5549e0a5555b0f668facfe83dad25206af92
- Commit:
-
70d819153ec3adb6251821610f273035087efc5d97f739c0faced78b8e09789511d08dadbdddfc3d
Checks run (2 succeeded)
-
-
"Review Bot" is the modern titling for the product, so the description should be reflective of that. (The repository has the old name for legacy purposes.)
-
-
-
-
unittest
is part of Python, so it should be in its own import group (which would come beforemock
's). -
/
isn't a safe assumption for path separators. Instead, whenever we need a path, we should build it withos.path.join
-
There's too much happening in this file and class. It'll get unwieldy as we go.
What we should do is have:
- A
testcase.py
file inbot/reviewbot/tools/tests/
that contains a baseBaseToolTestCase
class that tool-specific tests can inherit from. This should only contain generic methods that are useful for tool-related test suites. - A file per tool, named after the tool, that contains a test case class subclassing
BaseToolTestCase
that only contains functionality specific to that test.
We use this pattern in most of our code elsewhere.
- A
-
-
-
-
This doesn't quite match the way we do argument summaries. Something more like:
Each dictionary represents a file in the review. It must have the following keys: ``dest_file`` (:py:class:`unicode`): The filename of the diff being reviewed. ``patched_file_contents`` (:py:class:`bytes`): The contents of the diff for the file.
Something like that.
-
It would be really nice not to use
Mock
. While mocks can be useful, they can also make it increasingly harder to test real-world stuff. Instead, since we control theReview
andFile
classes, we should be using those instead. We can always use KGB to spy on any API requests to avoid those requests being made.By having the proper objects, we get increased testing of those objects, and we don't have to start going through and mocking more and more and more behavior as we add tests (diverging even further from core functionality and behavior and more toward mock-specific behavior).
-
-
-
-
-
-
Docstring summaries must be confined to one line. This can be:
Assert that comments in a review match expected comments.
-
-
For the tuples, turn them into literals, like:
... and value is a tuple in the form of ``(comment, line, issue)`` or ``(comment, line)``
so it's more clear.
-
Needs to be
bool, optional
, since the argument doesn't have to be provided.The content is also indented too far.
-
When we get rid of mocks, and use kgb, we'll be able to get rid of the
if
and just have the one loop and assertion, since kgb does the right thing with these calls and argument defaults. -
-
Make sure blank lines, indentation, types, and formatting are correct. Also, don't forget the
, optional
optional arguments.Types that are classes must be the absolute module path to the class.
-
-
Please use kgb instead of mocks here.
Also, these are very specific to flake8, which means this function is useless for every other type of tool. Either this should exist in a Flake8-specific test case, or should be made generic.
-
-
The format for testing docstrings should be in the form of:
"""Testing <toolname> with <condition>"""
This helps keep the output consistent and readable.
Also, no period at the end.
-
- Description:
-
~ Previously, we did not have tests for tools in ReviewBot.
~ Previously, we did not have tests for tools in Review Bot.
This change adds a framework for testing the output parsing logic of
~ the ReviewBot tool classes. Additionally, two sample unit tests have ~ the Review Bot tool classes. Additionally, two sample unit tests have been added to demonstrate how I envision this framework being used. - Commit:
-
97f739c0faced78b8e09789511d08dadbdddfc3d439194991888e023987be7b5ce2d51f3a4e4e0b6
- Description:
-
Previously, we did not have tests for tools in Review Bot.
This change adds a framework for testing the output parsing logic of
~ the Review Bot tool classes. Additionally, two sample unit tests have ~ the Review Bot tool classes. Additionally, some sample unit tests have been added to demonstrate how I envision this framework being used.