@pytest.mark.django_db
def test_otp(client):
    user = User.objects.create(email='example@example.com')
    token = user.otp_new(redirect='valid')
    response = client.post(token.path)
    assert (response['Location'] == 'valid')
    response = client.post(token.path)
    assert (response['Location'] != 'valid')
    token = user.otp_new()
    token.otp_expiry = (timezone.now() - timedelta(minutes=1))
    token.save()
    response = client.post(token.path)
    assert (response['Location'] != 'valid')
@pytest.mark.django_db
def test_otp(client):
    user = User.objects.create(email='example@example.com')
    token = user.otp_new(redirect='valid')
    response = client.post(token.path)
    assert (response['Location'] == 'valid')
    response = client.post(token.path)
    assert (response['Location'] != 'valid')
    token = user.otp_new()
    token.otp_expiry = (timezone.now() - timedelta(minutes=1))
    token.save()
    response = client.post(token.path)
    assert (response['Location'] != 'valid')