From 4941674421de0abc6ce966b5a7fe6cd997098630 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 14 Feb 2017 17:44:46 +0100 Subject: [PATCH] add test for new user registration --- rowers/tasks.py | 4 ++++ rowers/tests.py | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/rowers/tasks.py b/rowers/tasks.py index 1dc5d194..055dd524 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -244,6 +244,10 @@ def handle_sendemail_invite(email,name,code,teamname,manager): message = 'Dear '+name+',\n\n' message += manager+' is inviting you to join his team '+teamname message += ' on rowsandall.com\n\n' + message += 'By accepting the invite, you will have access to your' + message += " team's workouts on rowsandall.com and your workouts will " + message += " be visible to " + message += "the members of the team.\n\n" message += 'If you already have an account on rowsandall.com, you can login to the site and you will find the invitation here on the Teams page:\n' message += ' https://rowsandall.com/rowers/me/teams \n\n' message += 'You can also click the direct link: \n' diff --git a/rowers/tests.py b/rowers/tests.py index 569b9b11..50adfc20 100644 --- a/rowers/tests.py +++ b/rowers/tests.py @@ -2,7 +2,7 @@ from django.test import TestCase, Client,override_settings from django.test.client import RequestFactory from .views import checkworkoutuser,c2_open from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage -from rowers.forms import DocumentsForm,CNsummaryForm +from rowers.forms import DocumentsForm,CNsummaryForm,RegistrationFormUniqueEmail import rowers.plots as plots import rowers.interactiveplots as iplots import datetime @@ -276,6 +276,31 @@ class TestErrorPages(TestCase): self.assertEqual(response.status_code, 500) self.assertIn('500 Internal Server Error', unicode(response)) +class NewUserRegistrationTest(TestCase): + def setUp(self): + self.c = Client() + + def test_newuser(self): + form_data = { + 'first_name':'Jan', + 'last_name':'Roeiert', + 'email':'jan@loop.nl', + 'username':'janderoeiert', + 'password1':'aapindewei2', + 'password2':'aapindewei2', + 'tos':True, + } + + form = RegistrationFormUniqueEmail(form_data) + self.assertTrue(form.is_valid()) + + response = self.c.post('/rowers/register', form_data, follow=True) + + self.assertRedirects(response, + expected_url='/rowers/register/thankyou/', + status_code=302,target_status_code=200) + + class WorkoutTests(TestCase): def setUp(self): u = User.objects.create_user('john',