def testComment(self): self.client.login(email='*****@*****.**', password='******') comment_text = 'some various text for testing' check_redirect(lambda: self.client.post(self.p1.get_absolute_url(), {'body': comment_text})) self.comments = CommentNode.objects.for_object(self.p1) self.assertEquals(len(self.comments), 1) self.assertEquals(comment_text, self.comments[0].body)
def testLoggedOutComment(self): comment_text = 'another comment' data = {'body': comment_text, 'name': self.user.username, 'email': self.user.email, 'subscribe': True} check_redirect(lambda: self.client.post(self.p1.get_absolute_url(), data)) self.comments = CommentNode.all_objects.for_object(self.p1) self.assertEquals(len(self.comments), 1) self.assertEquals(comment_text, self.comments[0].body) self.assertEquals(len(mail.outbox), 1)
def testAnonymousComment(self): comment_text = 'one more comment' data = {'body': comment_text, 'name': 'somethingleft', 'email': '*****@*****.**', 'subscribe': True} check_redirect(lambda: self.client.post(self.p1.get_absolute_url(), data)) self.comments = CommentNode.all_objects.for_object(self.p1) self.assertEquals(len(self.comments), 1) self.assertEquals(comment_text, self.comments[0].body) # Posting second comment self.client.logout() data = {'body': 'completely useless', 'name': 'somethingright', 'email': '*****@*****.**', 'subscribe': True} check_redirect(lambda: self.client.post(self.p1.get_absolute_url(), data)) if not appcheck.watchlist: # Expect registration mails mailcount = 2 else: # Additionally two notification for comment author mailcount = 5 self.assertEquals(len(mail.outbox), mailcount)
def testEmailChange(self): self.assertEquals(self.client.login(email=self.old_email, password=self.name), True) check_redirect(lambda: self.client.post(reverse('profile_edit'), {'email': self.new_email})) self.assertEqual(len(mail.outbox), 1)