def test_pre_registration_with_token(client, mocker, before_registration_window):
    url = reverse_pre_registration_url('*****@*****.**')
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.get(url)

    assert response.status_code == status.HTTP_200_OK
Exemple #2
0
def test_pre_registration_with_token(client, mocker,
                                     before_registration_window):
    url = reverse_pre_registration_url('*****@*****.**')
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.get(url)

    assert response.status_code == status.HTTP_200_OK
def test_reversing_pre_registration_url():
    email_in = '*****@*****.**'
    url = reverse_pre_registration_url(email_in)
    base_url, _, qs = url.partition('?')
    params = urlparse.parse_qs(qs)
    assert 'token' in params
    email_out = unsign_pre_registration_token(params['token'][0])

    assert email_in == email_out
def test_pre_registration_with_correct_email_addess(client, mocker,
                                                    before_registration_window):
    url = reverse_pre_registration_url('*****@*****.**')
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.post(url, {
        'email': email,
        'phone_number': '555-444-3333',  # The form takes care of formatting.
    })

    assert response.status_code == status.HTTP_302_FOUND
Exemple #5
0
def test_pre_registration_with_correct_email_addess(
        client, mocker, before_registration_window):
    url = reverse_pre_registration_url('*****@*****.**')
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.post(
        url,
        {
            'email': email,
            'phone_number':
            '555-444-3333',  # The form takes care of formatting.
        })

    assert response.status_code == status.HTTP_302_FOUND
def test_pre_registration_email_contains_token(client, mocker,
                                               before_registration_window):
    token = generate_pre_registration_token('*****@*****.**')
    url = reverse_pre_registration_url('*****@*****.**', token=token)
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.post(url, {
        'email': email,
        'phone_number': '555-444-3333',  # The form takes care of formatting.
    })

    assert response.status_code == status.HTTP_302_FOUND

    message = mail.outbox[0]
    p1, p2, p3 = token.split(':')
    assert p1 in message.body
    assert p2 in message.body
    assert p3 in message.body
Exemple #7
0
def test_pre_registration_email_contains_token(client, mocker,
                                               before_registration_window):
    token = generate_pre_registration_token('*****@*****.**')
    url = reverse_pre_registration_url('*****@*****.**', token=token)
    email = '*****@*****.**'
    phone_number = '5554443333'

    response = client.post(
        url,
        {
            'email': email,
            'phone_number':
            '555-444-3333',  # The form takes care of formatting.
        })

    assert response.status_code == status.HTTP_302_FOUND

    message = mail.outbox[0]
    p1, p2, p3 = token.split(':')
    assert p1 in message.body
    assert p2 in message.body
    assert p3 in message.body
Exemple #8
0
 def form_valid(self, form):
     email = form.cleaned_data['email']
     token_url = self.request.build_absolute_uri(reverse_pre_registration_url(email))
     return self.render_to_response(self.get_context_data(form=form, token_url=token_url))
Exemple #9
0
 def form_valid(self, form):
     email = form.cleaned_data['email']
     token_url = self.request.build_absolute_uri(
         reverse_pre_registration_url(email))
     return self.render_to_response(
         self.get_context_data(form=form, token_url=token_url))