def test_non_mandatory_names(self): """ Check that non required parameters are not checked by is_valid method.""" data = { 'username':'******', 'email':'*****@*****.**', 'password':'******', 'password_check':'passwd' } form = UserForm(data) self.assertTrue(form.is_valid())
def test_valid_form(self): """" This method checks that the overriden method is_valid works.""" data = { 'username':'******', 'last_name':'bar', 'first_name':'baz', 'email':'*****@*****.**', 'password':'******', 'password_check':'passwd' } form = UserForm(data) self.assertTrue(form.is_valid())
def test_password_check(self): """ This methods checks that the 2 occurences of entered password are compared.""" data = { 'username':'******', 'last_name':'bar', 'first_name':'baz', 'email':'*****@*****.**', 'password':'******', 'password_check':'toto' } form = UserForm(data) self.assertFalse(form.is_valid())
def add(req): username = req.session['username'] uf = UserForm(req.GET) content = req.POST.get('content') title = req.POST.get('title') new = BLOG(username=username, title=title, content=content) new.save() return HttpResponseRedirect('/yunwei/blog')