Commit Graph

10 Commits

Author SHA1 Message Date
Ben Thorner
dcfff87cc0 Continue to remove "roles" terminology
This renames the two functions we have to translate between UI and
DB permissions, as well as some of their associated variables to
make it clearer which kind of permission they contain.
2021-07-28 12:37:17 +01:00
Ben Thorner
f5580b87dc Move tests to match where the code is located
These tests are unrelated to the others in test_permissions.py. We
should try and structure our tests the same as the code under test
so that it's clear where new tests should go.
2021-07-28 12:36:43 +01:00
Ben Thorner
9177ffa65a Clarify variable name in pagination tests
We should avoid using abbreviations, as they aren't universally
understood i.e. they're not worth the small saving in typing.
2021-06-16 16:08:38 +01:00
Ben Thorner
c17d438de8 DRY-up email revalidation check
Previously this was duplicated between the "two_factor" and the
"webauthn" views, and required more test setup. This DRYs up the
check and tests it once, using mocks to simplify the view tests.

As part of DRYing up the check into a util module, I've also moved
the "is_less_than_days_ago" function it uses.
2021-06-14 12:52:54 +01:00
Ben Thorner
edb0b8214d Move pagination utils into own module
This continues the pattern established in [1], just to chip away a
bit more at the random collection of stuff in utils/__init__.py.

[1]: https://github.com/alphagov/notifications-admin/pull/3923
2021-06-14 11:00:05 +01:00
Ben Thorner
adc49b8792 Add __init__.py file to make pytest happy
Otherwise we get the following error:

    ________________________________________ ERROR collecting tests/app/utils/test_user.py ________________________________________
    import file mismatch:
    imported module 'test_user' has this __file__ attribute:
      /Users/benthorner/Documents/Projects/admin/tests/app/models/test_user.py
    which is not the same as the test file we want to collect:
      /Users/benthorner/Documents/Projects/admin/tests/app/utils/test_user.py
    HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
2021-06-09 15:56:34 +01:00
Ben Thorner
35301df908 Relocate unit tests for user permission util
Previously these were lumped together with integration-level tests
for specific endpoints, which test the decorator was applied to the
endpoint in question.
2021-06-09 15:38:28 +01:00
Ben Thorner
aafb7e9182 Merge separate test for CSV errors function
It's not clear why this was separate from the other utils tests, or
why it was put under main/ - the code under test wasn't in there.
2021-06-09 15:19:01 +01:00
Ben Thorner
0326005aeb Extract template / csv utility code into modules
This follows a similar approach to the previous commits, noting that
one module depends on the other, so we have to extract both together.
2021-06-09 15:19:00 +01:00
Ben Thorner
2a4aa8b4e1 Extract letter utility code into own module
This provides more room for expansion, and reduces the amount of
arbitrary code in the __init__.py file for the new package.
2021-06-09 13:59:06 +01:00