Skip to content

test: Adding full unit test coverage for stripe/views.py

stephen requested to merge unit-tests--stripe-views into main

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/ and tests/stripe/json/ were created, and relevant test files moved into these directories from tests. Additionally, tests/stripe/__init__.py was created so that testing tools would search there for Python files.
  • test_stripe.py was renamed test_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 for tordonate/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 statement if 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 the if statement to prevent coverage.py from believing this convenience requires unit testing.
  • Where used, HttpResponseNotAllowed() is now properly instantiated with the ['POST'] parameter before being returned.

Merge request reports

Loading