summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
authoradityacp2018-01-17 17:23:48 +0530
committeradityacp2018-01-17 17:23:48 +0530
commitef9b17ffcf89a3ce90930f7ce4e91b481ad2a53a (patch)
treee55b42d29fb19a83c9c7afe5a71cb6978873a8d1 /yaksh/test_views.py
parent8006ffb4a5bd54aa960b24f1508d95844fa579de (diff)
downloadonline_test-ef9b17ffcf89a3ce90930f7ce4e91b481ad2a53a.tar.gz
online_test-ef9b17ffcf89a3ce90930f7ce4e91b481ad2a53a.tar.bz2
online_test-ef9b17ffcf89a3ce90930f7ce4e91b481ad2a53a.zip
Change views.py and test_views.py
- Add a condition to disallow a teacher to become course creator - Add test to check if a teacher does not become course creator
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 6444465..b4531a6 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -1916,6 +1916,25 @@ class TestAddCourse(TestCase):
timezone='UTC'
)
+ # Create a teacher
+ self.teacher_plaintext_pass = 'demo_teacher'
+ self.teacher = User.objects.create_user(
+ username='demo_teacher',
+ password=self.teacher_plaintext_pass,
+ first_name='first_name',
+ last_name='last_name',
+ email='demo@test.com'
+ )
+
+ Profile.objects.create(
+ user=self.teacher,
+ roll_number=10,
+ institute='IIT',
+ department='Chemical',
+ position='Moderator',
+ timezone='UTC'
+ )
+
# Create Student
self.student_plaintext_pass = 'demo_student'
self.student = User.objects.create_user(
@@ -1928,10 +1947,13 @@ class TestAddCourse(TestCase):
# Add to moderator group
self.mod_group.user_set.add(self.user)
+ self.mod_group.user_set.add(self.teacher)
self.course = Course.objects.create(name="Python Course",
enrollment="Enroll Request", creator=self.user)
+ self.course.teachers.add(self.teacher)
+
self.pre_req_quiz = Quiz.objects.create(
start_date_time=datetime(2014, 2, 1, 5, 8, 15, 0, tzone),
end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzone),
@@ -2021,6 +2043,33 @@ class TestAddCourse(TestCase):
self.assertRedirects(response, '/exam/manage/courses',
target_status_code=301)
+ def test_add_course_teacher_cannot_be_creator(self):
+ """
+ Teacher editing the course should not become creator
+ """
+ self.client.login(
+ username=self.teacher.username,
+ password=self.teacher_plaintext_pass
+ )
+
+ response = self.client.post(reverse('yaksh:edit_course',
+ kwargs={"course_id": self.course.id}),
+ data={'name': 'Teacher_course',
+ 'active': True,
+ 'enrollment': 'open',
+ 'start_enroll_time': '2016-01-10 09:00:15',
+ 'end_enroll_time': '2016-01-15 09:00:15',
+ }
+ )
+ updated_course = Course.objects.get(id=self.course.id)
+ self.assertEqual(updated_course.name, 'Teacher_course')
+ self.assertEqual(updated_course.enrollment, 'open')
+ self.assertEqual(updated_course.active, True)
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(updated_course.creator, self.user)
+ self.assertRedirects(response, '/exam/manage/courses',
+ target_status_code=301)
+
class TestCourseDetail(TestCase):
def setUp(self):