test: Adding full unit test coverage for stripe/views.py
This commit adds full unit test support for /tordonate/stripe/views.py
and modifies the directory structure and filename convention inside
/tordonate/tests
to better reflect the structure and layout of files
being tested.
- The folders
tests/stripe/
andtests/stripe/json/
were created, and relevant test files moved into these directories fromtests
. Additionally,tests/stripe/__init__.py
was created so that testing tools would search there for Python files. -
test_stripe.py
was renamedtest_stripe_views.py
to better reflect the particular unit tests found therein. -
test_stripe_views.py
was greatly expanded and now provides 100% test coverage fortordonate/stripe/views.py
. - Test coverage now contains negative testing for incorrect input and (where appropriate) attempts to access POST-only route URLs via GET.
In addition to these changes, some minor updates were made in
stripe/views.py
to better accomodate testing:
- Some imports are made in
views.py
but tucked behind the statementif t.TYPE_CHECKING:
for the sake of type hinting (as discussed here: https://mypy.readthedocs.io/en/stable/runtime_troubles.html) We now additionally comment# pragma: no cover
beside theif
statement to preventcoverage.py
from believing this convenience requires unit testing. - Where used,
HttpResponseNotAllowed()
is now properly instantiated with the['POST']
parameter before being returned.