class TestRestAssignmentListing(TestCase): def setUp(self): self.testhelper = TestHelper() #self.testhelper.add(nodes='uni:admin(uniadmin)', #subjects=['duck2000:admin(adminone,admintwo):ln(Something fancy)', #'duck3000', #'duck1000:admin(adminone)', #'duck4000:admin(adminone,admintwo,singleadmin)']) self.client = RestClient() def _get(self, **data): return self.client.rest_get(reverse('devilry_examiner-rest-assignmentlisting'), **data) def _getas(self, username, **data): self.client.login(username=username, password='******') return self._get(**data) def test_get(self): self.testhelper.create_user('examiner1') content, response = self._getas('examiner1') self.assertEquals(response.status_code, 200) self.assertEquals(content, ['Hello', 'world']) def test_get_noauth(self): content, response = self._get() self.assertEquals(response.status_code, 401)
class TestRestAggregatedStudentInfo(TestCase): def setUp(self): self.testhelper = TestHelper() self.client = RestClient() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1,student2):examiner(examiner1).d1:ends(5)') self.group = self.testhelper.sub_p1_a1_g1 def _get(self, user_id): return self.client.rest_get(reverse('devilry_nodeadmin-aggregatedstudentinfo', kwargs={'user_id': user_id})) def _getas(self, username, id): self.client.login(username=username, password='******') return self._get(id) def test_get(self): content, response = self._getas('uniadmin', self.testhelper.student1.id) self.assertEquals(response.status_code, 200) user = {u'username': u'student1', u'displayname': u'student1', u'id': 2, u'full_name': None, u'email': u'*****@*****.**'} self.assertEquals(content['user'], user) grouped_by_hierarky = content['grouped_by_hierarky'][0] self.assertEquals(set(grouped_by_hierarky.keys()), set([u'long_name', u'id', u'short_name', u'periods'])) period = grouped_by_hierarky['periods'][0] self.assertEquals(set(period.keys()), set([u'short_name', u'assignments', u'is_relatedstudent', u'start_time', u'is_active', u'qualified_forexams', u'long_name', u'end_time', u'id'])) assignments = period['assignments'][0] self.assertEquals(set(period.keys()), set([u'short_name', u'assignments', u'is_relatedstudent', u'start_time', u'is_active', u'qualified_forexams', u'long_name', u'end_time', u'id'])) groups = assignments['groups'][0] self.assertEquals(set(groups.keys()), set([u'status', u'active_feedback', u'id'])) def test_get_noauth(self): content, response = self._get(self.testhelper.student1.id) self.assertEquals(response.status_code, 401)
class TestRestRecentDeliveries(TestCase): def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1).d1') self.group = self.testhelper.sub_p1_a1_g1 self.url = '/devilry_student/rest/recent-deliveries/' def _getas(self, username): self.client.login(username=username, password='******') return self.client.rest_get(self.url) def test_nobody(self): fileinfo = {'ok.py': ['print ', 'meh']} self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) self.testhelper.create_user('nobody') content, response = self._getas('nobody') self.assertEquals(response.status_code, 200) self.assertEquals(content, []) def test_recent_deliveries_minimal(self): fileinfo = {'ok.py': ['print ', 'meh']} self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) content, response = self._getas('student1') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 1) self.assertEquals(set(content[0].keys()), set(['id', 'assignment', 'period', 'subject', 'time_of_delivery', 'group', 'number'])) assignment = self.group.parentnode period = self.group.parentnode.parentnode subject = self.group.parentnode.parentnode.parentnode self.assertEquals(content[0]['assignment'], {u'id': assignment.id, u'long_name': u'A1', u'short_name': u'a1'}) self.assertEquals(content[0]['period'], {u'id': period.id, u'long_name': u'P1', u'short_name': u'p1'}) self.assertEquals(content[0]['subject'], {u'id': subject.id, u'long_name': u'Sub', u'short_name': u'sub'}) def test_recent_deliveries_over10(self): fileinfo = {'ok.py': ['print ', 'meh']} for x in xrange(8): self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) content, response = self._getas('student1') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 6)
class TestRestFindGroups(TestCase): def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p0:begins(-10):ends(2)', 'p1:begins(-1)', 'p2:begins(5)'], assignments=['a1']) self.testhelper.create_user('testuser') self.url = '/devilry_student/rest/find-groups/' def _getas(self, username, **data): self.client.login(username=username, password='******') return self.client.rest_get(self.url, **data) def test_find_groups_empty(self): content, response = self._getas('testuser') self.assertEquals(response.status_code, 200) self.assertEquals(content, []) def test_find_groups(self): # Add to the past period (should show up) self.testhelper.add_to_path('uni;sub.p0.a1.gOld:candidate(student1).d1') # Add to the active period (show show up) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1).d1') self.testhelper.add_to_path('uni;sub.p1.a1.g2:candidate(student1,student2).d1') # Add to the future period (should not show up) self.testhelper.add_to_path('uni;sub.p2.a1.gFut:candidate(student1).d1') content, response = self._getas('student1', query='sub') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 3) self.assertEquals(set(content[0].keys()), set(['id', 'name', 'assignment', 'period', 'subject'])) groupnames = set([group['name'] for group in content]) self.assertEquals(groupnames, set(['g1', 'g2', 'gOld'])) content, response = self._getas('student1', query='old') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 1) content, response = self._getas('student1', query='p1 g2') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 1) self.assertEquals(content[0]['name'], 'g2')
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:admin(p1admin)', 'p2']) self.client = RestClient() self.url = '/devilry_subjectadmin/rest/createnewassignment/'
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['sub'], periods=['p1:admin(p1admin)', 'p2:admin(p2admin)']) self.client = RestClient()
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['sub'], periods=['p1:admin(periodadmin):begins(-3):ends(6)']) self.client = RestClient() self.testhelper.create_superuser('superuser')
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:admin(p1admin)', 'p2:admin(p2admin)']) self.testhelper.create_superuser("superuser") self.testhelper.create_user('testuser')
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:admin(p1admin)', 'p2:admin(p2admin)']) self.testhelper.create_superuser("superuser") self.testreluser = self.create_reluser_on_p1('testuser', tags='group1,group2')
class TestRestRecentFeedbacks(TestCase): def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1):examiner(examiner1).d1') self.group = self.testhelper.sub_p1_a1_g1 self.url = '/devilry_student/rest/recent-feedbacks/' def _getas(self, username): self.client.login(username=username, password='******') return self.client.rest_get(self.url) def test_nobody(self): fileinfo = {'ok.py': ['print ', 'meh']} self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) self.testhelper.create_user('nobody') content, response = self._getas('nobody') self.assertEquals(response.status_code, 200) self.assertEquals(content, []) def test_recent_feedbacks_minimal(self): fileinfo = {'ok.py': ['print ', 'meh']} delivery = self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) self.testhelper.add_feedback(delivery, verdict={'grade': 'F', 'points': 30, 'is_passing_grade': False}) content, response = self._getas('student1') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 1) self.assertEquals(set(content[0].keys()), set(['id', 'assignment', 'period', 'subject', 'number', 'last_feedback', 'group'])) def test_recent_deliveries_overflow(self): fileinfo = {'ok.py': ['print ', 'meh']} for x in xrange(8): delivery = self.testhelper.add_delivery('sub.p1.a1.g1', fileinfo) self.testhelper.add_feedback(delivery, verdict={'grade': '{0}/100'.format(x), 'points': x, 'is_passing_grade': False}) content, response = self._getas('student1') self.assertEquals(response.status_code, 200) self.assertEquals(len(content), 6)
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-2)'], # 2 months ago assignments=['a1:admin(adm):pub(0)']) # 0 days after period begins self.client = RestClient() self.url = '/devilry_subjectadmin/rest/deadlinesbulk/{0}/'.format(self.testhelper.sub_p1_a1.id)
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add( nodes="uni", subjects=["sub"], periods=["p1:begins(-2)"], assignments=["a1:admin(a1admin)"] # 2 months ago ) self.assignment = self.testhelper.sub_p1_a1 self.url = "/devilry_subjectadmin/rest/mergeintogroup/{0}".format(self.assignment.id)
def setUp(self): self.testhelper = TestHelper() #self.testhelper.add(nodes='uni:admin(uniadmin)', #subjects=['duck2000:admin(adminone,admintwo):ln(Something fancy)', #'duck3000', #'duck1000:admin(adminone)', #'duck4000:admin(adminone,admintwo,singleadmin)']) self.client = RestClient()
class TestRestPreview(TestCase): def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['sub'], periods=['p1:admin(periodadmin):begins(-3):ends(6)']) self.client = RestClient() self.testhelper.create_superuser('superuser') def _get_url(self, periodid): return reverse('devilry_qualifiesforexam-rest-preview', kwargs={'id': periodid}) def _getas(self, username, periodid, previewdata, pluginsessionid='tst'): self.client.login(username=username, password='******') session = self.client.session session['qualifiesforexam-{0}'.format(pluginsessionid)] = previewdata session.save() return self.client.rest_get(self._get_url(periodid), pluginsessionid=pluginsessionid) def _test_getas(self, username): content, response = self._getas(username, self.testhelper.sub_p1.id, PreviewData(passing_relatedstudentids=[1, 2, 4])) self.assertEqual(response.status_code, 200) self.assertEqual(set(content.keys()), set(['pluginoutput', 'perioddata'])) self.assertEqual(content['pluginoutput'], {u'passing_relatedstudentids': [1, 2, 4]}) def test_get_as_periodadmin(self): self._test_getas('periodadmin') def test_get_as_nodeadmin(self): self._test_getas('uniadmin') def test_get_as_superuser(self): self._test_getas('superuser') def test_getas_nobody(self): self.testhelper.create_user('nobody') content, response = self._getas('nobody', self.testhelper.sub_p1.id, PreviewData(passing_relatedstudentids=[])) self.assertEqual(response.status_code, 403) def test_get_invalid_period(self): periodid = 10000 self.assertFalse(Period.objects.filter(id=periodid).exists()) # Just to be sure we dont get false positives content, response = self._getas('periodadmin', periodid, PreviewData(passing_relatedstudentids=[])) self.assertEqual(response.status_code, 403)
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['duck2000:admin(duck2000admin)'], periods=['periodone:admin(oneadmin)', 'periodtwo', 'periodthree:admin(adminone)']) self.client = RestClient()
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['duck2000:admin(duck2000admin)'], periods=['someperiod:begins(-2):ends(6)'], assignments=['first:admin(firstadmin)', 'second:admin(secondadmin,firstadmin)', 'third']) self.client = RestClient()
def setUp(self): self.testhelper = TestHelper() self.testhelper.add( nodes="uni:admin(uniadmin)", subjects=["duck2000:admin(duck2000admin)"], periods=["someperiod:begins(-2):ends(6)"], assignments=["first:admin(firstadmin)", "second:admin(secondadmin,firstadmin)", "third"], ) self.client = RestClient()
def setUp(self): self.testhelper = TestHelper() self.client = RestClient() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1,student2):examiner(examiner1).d1:ends(5)') self.group = self.testhelper.sub_p1_a1_g1
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['old:begins(-14):ends(6)', # 14 months ago 'cur:begins(-2)'], # 2 months ago assignments=['a1:admin(adm):pub(0)']) # 0 days after period begins self.client = RestClient() self.url = '/devilry_subjectadmin/rest/passedinpreviousperiod/{0}'.format(self.testhelper.sub_cur_a1.id)
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-2)'], # 2 months ago assignments=['a1:admin(a1admin)']) self.assignment = self.testhelper.sub_p1_a1 self.url = '/devilry_subjectadmin/rest/popfromgroup/{0}'.format(self.assignment.id)
class TestRestAggregatedGroupInfo(TestCase): def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1:admin(a1admin)']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1,student2):examiner(examiner1).d1:ends(5)') self.testhelper.add_to_path('uni;sub.p1.a1.g1.d2:ends(10)') self.group = self.testhelper.sub_p1_a1_g1 self.url = '/devilry_subjectadmin/rest/aggregated-groupinfo/{0}'.format(self.group.id) def _getas(self, username): self.client.login(username=username, password='******') return self.client.rest_get(self.url) def test_nobody(self): self.testhelper.create_user('nobody') content, response = self._getas('nobody') self.assertEquals(response.status_code, 403) def test_groupinfo(self): content, response = self._getas('a1admin') self.assertEquals(response.status_code, 200) self.assertEquals(set(content.keys()), set(['id', 'deadlines'])) self.assertEquals(content['id'], self.group.id) def test_groupinfo_superuser(self): self.testhelper.create_superuser('superuser') content, response = self._getas('superuser') self.assertEquals(response.status_code, 200) self.assertEquals(set(content.keys()), set(['id', 'deadlines'])) self.assertEquals(content['id'], self.group.id) def test_deadlines(self): content, response = self._getas('a1admin') deadlines = content['deadlines'] self.assertEquals(len(deadlines), 2) self.assertEquals(set(deadlines[0].keys()), set(['id', 'deadline', 'deliveries', 'text', 'offset_from_now', 'in_the_future']))
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['duck2000:admin(subadmin)'], periods=['one:admin(adminone)', 'two', 'three:admin(adminone)']) self.client = RestClient() self.url = '/devilry_subjectadmin/rest/period/' self.testhelper.create_user('nobody')
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1):examiner(examiner1).d1') self.group = self.testhelper.sub_p1_a1_g1 self.url = '/devilry_student/rest/recent-feedbacks/'
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin)', subjects=['duck2000:admin(adminone,admintwo):ln(Something fancy)', 'duck3000', 'duck1000:admin(adminone)', 'duck4000:admin(adminone,admintwo,singleadmin)']) self.client = RestClient() self.url = '/devilry_subjectadmin/rest/subject/' self.testhelper.create_user('nobody')
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni:admin(uniadmin):ln(Test Uni)', subjects=['sub:admin(subadmin):ln(Test Sub)'], periods=['p1:begins(-2):admin(p1admin):ln(Test P1)'], assignments=['a1:admin(a1admin):ln(Test A1)'], assignmentgroups=['TestGroup1:candidate(student1)'] ) self.client = RestClient() self.url = reverse('devilry_search_admincontent')
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p0:begins(-10):ends(2)', 'p1:begins(-2):ends(6)', 'p2:begins(5)'], assignments=['a1:pub(1)', 'a2:pub(2)', 'a3:pub(3)']) self.testhelper.create_user('testuser') self.url = reverse('devilry_student-rest-results')
def setUp(self): self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1'], assignments=['a1:admin(a1admin)']) self.client = RestClient() self.testhelper.create_user('candidate1') self.testhelper.create_user('examiner1') self.testhelper.create_superuser('grandma') self.a1id = self.testhelper.sub_p1_a1.id
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1'], assignments=['a1:admin(a1admin)', 'a2:admin(a2admin)']) self.testhelper.add_to_path('uni;sub.p2') self.testhelper.create_superuser("superuser") self.testhelper.create_user('testuser')
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p1:begins(-1)'], assignments=['a1']) self.testhelper.add_to_path('uni;sub.p1.a1.g1:candidate(student1,student2):examiner(examiner1).d1:ends(5)') self.testhelper.add_to_path('uni;sub.p1.a1.g1.d2:ends(10)') self.group = self.testhelper.sub_p1_a1_g1 self.url = '/devilry_student/rest/aggregated-groupinfo/{0}'.format(self.group.id)
def setUp(self): self.client = RestClient() self.testhelper = TestHelper() self.testhelper.add(nodes='uni', subjects=['sub'], periods=['p0:begins(-10):ends(2)', 'p1:begins(-1)', 'p2:begins(5)'], assignments=['a1']) self.testhelper.create_user('testuser') self.url = '/devilry_student/rest/find-groups/'