summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-05-05 17:47:27 +0530
committerGitHub2017-05-05 17:47:27 +0530
commitb6993d79ae2f0d18375555f5ada72b52a3a2e066 (patch)
tree19326254303a5ff03697371ed198f89e1145db9b /yaksh/test_views.py
parent4cd448769c6cc230b7a33a1848cc45873b578468 (diff)
parentd7e6430d8c48381c6660906ab3a96251824f9031 (diff)
downloadonline_test-b6993d79ae2f0d18375555f5ada72b52a3a2e066.tar.gz
online_test-b6993d79ae2f0d18375555f5ada72b52a3a2e066.tar.bz2
online_test-b6993d79ae2f0d18375555f5ada72b52a3a2e066.zip
Merge pull request #290 from adityacp/email_verifcation_testing
Email verification testing
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 3fcdde2..37e5ce4 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -7,6 +7,7 @@ from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test import Client
from django.utils import timezone
+from django.core import mail
from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\
QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\
@@ -97,6 +98,31 @@ class TestProfile(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'yaksh/view_profile.html')
+ def test_email_verification_for_user_post(self):
+ """
+ POST request to verify email
+ """
+ self.client.login(
+ username=self.user2.username,
+ password=self.user2_plaintext_pass
+ )
+ post_response = self.client.post(reverse('yaksh:new_activation'),
+ data={'email':self.user2.email}
+ )
+ subject = mail.outbox[0].subject.replace(" ", "_")
+ activation_key = mail.outbox[0].body.split("\n")[2].split("/")[-1]
+ get_response = self.client.get(reverse('yaksh:activate',
+ kwargs={'key': activation_key}),
+ follow=True
+ )
+ updated_profile_user = User.objects.get(id=self.user2.id)
+ updated_profile = Profile.objects.get(user=updated_profile_user)
+ self.assertEqual(post_response.status_code, 200)
+ self.assertEqual(subject, "Yaksh_Email_Verification")
+ self.assertEqual(get_response.status_code, 200)
+ self.assertEqual(updated_profile.is_email_verified, True)
+ self.assertTemplateUsed(get_response, 'yaksh/activation_status.html')
+
def test_edit_profile_post(self):
"""
POST request to edit_profile view should update the user's profile
@@ -141,6 +167,25 @@ class TestProfile(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'yaksh/editprofile.html')
+ def test_update_email_for_user_post(self):
+ """ POST request to update email if multiple users with same email are
+ found
+ """
+ self.client.login(
+ username=self.user2.username,
+ password=self.user2_plaintext_pass
+ )
+ response = self.client.post(reverse('yaksh:update_email'),
+ data={
+ 'username': self.user2.username,
+ 'email':"demo_user2@mail.com"
+ }
+ )
+ updated_user = User.objects.get(id=self.user2.id)
+ self.assertEqual(updated_user.email, "demo_user2@mail.com")
+ self.assertEqual(response.status_code, 200)
+ self.assertTemplateUsed(response, 'yaksh/activation_status.html')
+
class TestAddQuiz(TestCase):
def setUp(self):