示例#1
0
def test_save_nonexistent_email(mock_send_confirmation, db):
    """
    If the provided email address is not in the database, no action
    should be taken.
    """
    data = {"email": "*****@*****.**"}

    serializer = serializers.ResendVerificationSerializer(data=data)
    assert serializer.is_valid()

    serializer.save()

    assert mock_send_confirmation.call_count == 0
示例#2
0
def test_save(mock_send_confirmation, email_factory):
    """
    Saving the serializer should send a new confirmation.
    """
    email = email_factory()

    data = {"email": email.email}

    serializer = serializers.ResendVerificationSerializer(data=data)
    assert serializer.is_valid()

    serializer.save()

    assert mock_send_confirmation.call_count == 1
示例#3
0
def test_post_resend_verification(api_client):
    """
    Sending a POST request to the endpoint should send a confirmation
    email to the provided address.
    """
    data = {"email": "*****@*****.**"}

    response = api_client.post(url, data)

    assert response.status_code == status.HTTP_200_OK

    serializer = serializers.ResendVerificationSerializer(data=data)
    assert serializer.is_valid()

    assert response.data == serializer.data
示例#4
0
def test_save_verified_email(mock_send_confirmation, email_factory):
    """
    If the provided email has already been verified, no action should be
    taken.
    """
    email = email_factory(is_verified=True)

    data = {"email": email.email}

    serializer = serializers.ResendVerificationSerializer(data=data)
    assert serializer.is_valid()

    serializer.save()

    assert mock_send_confirmation.call_count == 0