summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
authorprathamesh2017-11-07 13:12:06 +0530
committerprathamesh2017-11-07 13:12:06 +0530
commit2eee8fa300a4776647a7be7fdb9dee082f4d6fd8 (patch)
tree4accd8bd91529d6458fbe940f31a3a5e42a874aa /yaksh/test_views.py
parent4c1ddc15f3b9a15bee49ac2f6640c8ed311f7151 (diff)
parent807a52e45a9b6c6ac64a7a5e4bd8248900fb4367 (diff)
downloadonline_test-2eee8fa300a4776647a7be7fdb9dee082f4d6fd8.tar.gz
online_test-2eee8fa300a4776647a7be7fdb9dee082f4d6fd8.tar.bz2
online_test-2eee8fa300a4776647a7be7fdb9dee082f4d6fd8.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into detailed_csv_download_quiz
Resolved Conflicts: CHANGELOG.txt
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index af9ac7d..e3b0168 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -196,6 +196,38 @@ class TestProfile(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'yaksh/profile_updated.html')
+ def test_edit_profile_post_for_user_without_profile(self):
+ """
+ POST request to edit_profile view should update the user's profile
+ """
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ response = self.client.post(reverse('yaksh:edit_profile'),
+ data={
+ 'user': self.user1,
+ 'first_name': 'new_first_name',
+ 'last_name': 'new_last_name',
+ 'roll_number': 21,
+ 'institute': 'new_institute',
+ 'department': 'Aerospace',
+ 'position': 'new_position',
+ 'timezone': 'UTC'
+ }
+ )
+ updated_profile_user = User.objects.get(id=self.user1.id)
+ updated_profile = Profile.objects.get(user=updated_profile_user)
+ self.assertEqual(updated_profile_user.first_name, 'new_first_name')
+ self.assertEqual(updated_profile_user.last_name, 'new_last_name')
+ self.assertEqual(updated_profile.roll_number, '21')
+ self.assertEqual(updated_profile.institute, 'new_institute')
+ self.assertEqual(updated_profile.department, 'Aerospace')
+ self.assertEqual(updated_profile.position, 'new_position')
+
+ self.assertEqual(response.status_code, 200)
+ self.assertTemplateUsed(response, 'yaksh/profile_updated.html')
+
def test_edit_profile_get(self):
"""
GET request to edit profile should display profile form