Clean up and consolidate avatar unit tests
Review Request #8528 — Created Nov. 7, 2016 and submitted
The avatar services tests had a few issues, namely:
- not resetting the registry after test completion;
- templatetag tests being spread out over two files;
- some tests not being updated for the new avatar services API; and
- using improper methods to generate dummy requests.
Some of these issues were causing test failures, while others were more
stylistic issues. All of these issues have been fixed and the avatar
unit tests now all pass.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
'User' imported but unused |
reviewbot | |
'HttpRequest' imported but unused |
reviewbot | |
'Profile' imported but unused |
reviewbot | |
'avatar_services' imported but unused |
reviewbot | |
Can you put all of this into parens? |
david | |
Here too? |
david | |
And here? |
david | |
And here? |
david | |
Alphabetical order. |
chipx86 | |
Doesn't this leak state that could theoretically impact other tests? Can we instead save/restore values? Also, it looks like we're … |
chipx86 |
-
I think we should have a
reviewboard/avatars/tests/
, and havetest_templatetags.py
inside of that, instead of havingtests.py
inreviewboard/avatars/templatetags/
.The reason is that, as test suites grow, we tend to split things out into a
tests/
directory within the app directory, and all unit tests in there. If we were to do that, but template tag tests lived inside thetemplatetags/
directory, it wouldn't be run as part of the test suite.It also avoids importing
tests.py
in production, which Django will do when looking for template registries.