diff options
author | ankitjavalkar | 2019-01-24 16:58:19 +0530 |
---|---|---|
committer | ankitjavalkar | 2019-01-24 16:58:19 +0530 |
commit | 7f91d11b37aaeb5a673f623d21ff2390983e0f8c (patch) | |
tree | 32a6095973f3bc4f198942fd416da870847058d8 | |
parent | 1d9f198ff5eb23bb4b73251c54e686bde1485af8 (diff) | |
download | online_test-7f91d11b37aaeb5a673f623d21ff2390983e0f8c.tar.gz online_test-7f91d11b37aaeb5a673f623d21ff2390983e0f8c.tar.bz2 online_test-7f91d11b37aaeb5a673f623d21ff2390983e0f8c.zip |
Add Test Cases
-rw-r--r-- | yaksh/test_models.py | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index c9cb953..aea47de 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -285,19 +285,49 @@ class LearningUnitTestCases(unittest.TestCase): class ProfileTestCases(unittest.TestCase): def setUp(self): - self.user1 = User.objects.get(username='creator') - self.profile = Profile.objects.get(user=self.user1) - self.user2 = User.objects.get(username='demo_user3') + self.creator = User.objects.get(username='creator') + self.profile = Profile.objects.get(user=self.creator) + self.teacher = User.objects.create_user(username='teacher_profile', + password='teacher_profile', + email='teacher_profile@test.com') + Profile.objects.create( + user=self.teacher, roll_number=123, institute='IIT', + is_moderator=True, department='Chemical', position='Teacher' + ) + self.course = Course.objects.create( + name="Course For ProfileTestCase", + enrollment="Open Course", + creator=self.creator, + start_enroll_time=datetime( + 2015, 10, 9, 10, 8, 15, 0, + tzinfo=pytz.utc + ), + end_enroll_time=datetime( + 2015, 11, 9, 10, 8, 15, 0, + tzinfo=pytz.utc + ), + ) + self.course.add_teachers(self.teacher) def test_user_profile(self): """ Test user profile""" - self.assertEqual(self.user1.username, 'creator') + self.assertEqual(self.creator.username, 'creator') self.assertEqual(self.profile.user.username, 'creator') self.assertEqual(int(self.profile.roll_number), 1) self.assertEqual(self.profile.institute, 'IIT') self.assertEqual(self.profile.department, 'Chemical') self.assertEqual(self.profile.position, 'Student') + def test_profile_is_moderator_removes_teacher(self): + teacher_profile = self.teacher.profile + teacher_profile.is_moderator = False + teacher_profile.save() + self.assertNotIn(self.teacher, self.course.teachers.all()) + + def tearDown(self): + self.teacher.profile.delete() + self.teacher.delete() + self.course.delete() ############################################################################### class QuestionTestCases(unittest.TestCase): |