mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-04 21:51:43 -04:00
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.
20 lines
606 B
Python
20 lines
606 B
Python
import pytest
|
|
from freezegun import freeze_time
|
|
|
|
from app.models.user import User
|
|
from app.utils.login import email_needs_revalidating
|
|
|
|
|
|
@freeze_time('2020-11-27T12:00:00')
|
|
@pytest.mark.parametrize(('email_access_validated_at', 'expected_result'), (
|
|
('2020-10-01T11:35:21.726132Z', False),
|
|
('2020-07-23T11:35:21.726132Z', True),
|
|
))
|
|
def test_email_needs_revalidating(
|
|
api_user_active,
|
|
email_access_validated_at,
|
|
expected_result,
|
|
):
|
|
api_user_active['email_access_validated_at'] = email_access_validated_at
|
|
assert email_needs_revalidating(User(api_user_active)) == expected_result
|