diff options
Diffstat (limited to 'yaksh/tests.py')
-rw-r--r-- | yaksh/tests.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/yaksh/tests.py b/yaksh/tests.py index d6d1d91..d69882d 100644 --- a/yaksh/tests.py +++ b/yaksh/tests.py @@ -3,7 +3,7 @@ from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ QuestionSet, AnswerPaper, Answer, TestCase, Course import json from datetime import datetime, timedelta - +from django.contrib.auth.models import Group def setUpModule(): # create user profile @@ -21,6 +21,11 @@ def setUpModule(): Profile.objects.create(user=student, roll_number=3, institute='IIT', department='Chemical', position='Student') + # create group + group = Group(name="moderator") + group.save() + student.groups.add(group) + # create a course course = Course.objects.create(name="Python Course", enrollment="Enroll Request", creator=user) @@ -57,6 +62,7 @@ class ProfileTestCases(unittest.TestCase): def setUp(self): self.user = User.objects.get(pk=1) self.profile = Profile.objects.get(pk=1) + self.user1 = User.objects.get(pk=3) def test_user_profile(self): """ Test user profile""" @@ -67,6 +73,11 @@ class ProfileTestCases(unittest.TestCase): self.assertEqual(self.profile.department, 'Chemical') self.assertEqual(self.profile.position, 'Student') + def test_is_moderator(self): + result = self.user1.profile.is_moderator(self.user1) + self.assertTrue(result) + result = self.user.profile.is_moderator(self.user) + self.assertFalse(result) ############################################################################### class QuestionTestCases(unittest.TestCase): @@ -437,3 +448,9 @@ class CourseTestCases(unittest.TestCase): def test_get_quizzes(self): """ Test get_quizzes method of Courses""" self.assertSequenceEqual(self.course.get_quizzes(), [self.quiz1, self.quiz2]) + + def test_add_teachers(self): + """ Test to add teachers to a course""" + added_list, rejected_list = self.course.add_teachers(self.student1, self.student2) + self.assertSequenceEqual(added_list, [self.student2]) + self.assertSequenceEqual(rejected_list, [self.student1]) |