def test_is_relatedstudent(self):
     PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser)
     response = self._get_as('testuser')
     self.assertEquals(response.status_code, 200)
     selector = htmls.S(response.content)
     self.assertEquals(selector.count('#objecttableview-table tbody tr'), 1)
 def test_is_active(self):
     PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser)
     response = self._get_as('testuser')
     self.assertEquals(response.status_code, 200)
     selector = htmls.S(response.content)
     self.assertTrue(
         selector.exists('#objecttableview-table tbody tr td:nth-child(1) '
                         'strong.devilry-student-allperiodsapp-isactive'))
 def test_qualifies_for_final_exam_not_set(self):
     PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser)
     response = self._get_as('testuser')
     self.assertEquals(response.status_code, 200)
     selector = htmls.S(response.content)
     self.assertFalse(
         selector.exists('#objecttableview-table tbody tr td:nth-child(1) '
                         '.devilry-student-allperiodsapp-qualified-for-final-exam-wrapper'))
 def test_waiting_for_deliveries_only_owned(self):
     PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('testassignment')\
         .add_group(students=[UserBuilder('otheruser').user])\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery_x_hours_before_deadline(hours=1)
     response = self._get_as('testuser')
     self.assertEquals(response.status_code, 200)
     selector = htmls.S(response.content)
     self.assertEquals(selector.count('#objecttableview-table tbody tr'), 0)
Esempio n. 5
0
    def test_invite_email(self):
        group = PeriodBuilder.quickadd_ducku_duck1010_active() \
            .add_relatedstudents(self.testuser2) \
            .add_assignment('assignment1', students_can_create_groups=True) \
            .add_group(students=[self.testuser1]).group
        invite = group.groupinvite_set.create(sent_by=self.testuser1,
                                              sent_to=self.testuser2)
        self.assertEqual(len(mail.outbox), 0)

        class FakeRequest(object):
            def build_absolute_uri(self, location):
                return 'http://example.com{}'.format(location)

        invite.send_invite_notification(FakeRequest())
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, ['*****@*****.**'])
        self.assertEqual(
            mail.outbox[0].subject,
            '[Devilry] Project group invite for duck1010.active.assignment1')
        self.assertIn(
            u'testuser1 invited you to join their project\ngroup for duck1010 assignment1.',
            mail.outbox[0].body)
        self.assertIn(
            'http://example.com{}'.format(
                reverse('devilry_student_groupinvite_respond',
                        kwargs={'invite_id': invite.id})), mail.outbox[0].body)
    def test_smart_create_non_electronic(self):
        assignment = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_assignment('assignment1', delivery_types=deliverytypes.NON_ELECTRONIC).assignment
        group1 = AssignmentGroup(parentnode=assignment)
        group2 = AssignmentGroup(parentnode=assignment)
        for group in group1, group2:
            group.save(autocreate_first_deadline_for_nonelectronic=False)
        deadline_datetime = Deadline.reduce_datetime_precision(DateTimeBuilder.now().plus(days=10))
        result = Deadline.objects.smart_create(
            assignment.assignmentgroups.all(),
            deadline_datetime=deadline_datetime,
            text='Hello world')
        self.assertIsNone(result)
        self.assertEquals(group1.deadlines.count(), 1)

        group1 = AssignmentGroup.objects.get(id=group1.id) # Reload from db
        created_deadline = group1.deadlines.all()[0]
        self.assertEquals(created_deadline.deadline, deadline_datetime)
        self.assertEquals(created_deadline.text, 'Hello world')
        self.assertEquals(group1.last_deadline, created_deadline)
        self.assertEquals(group1.last_deadline.deliveries.count(), 1)
        group1_last_delivery = Delivery.objects.filter(deadline__assignment_group=group1).first()
        self.assertEquals(group1.last_deadline.deliveries.all()[0], group1_last_delivery)
        self.assertTrue(group1_last_delivery.successful)
        self.assertEquals(group1_last_delivery.number, 1)

        group2 = AssignmentGroup.objects.get(id=group2.id) # Reload from db
        self.assertEquals(group2.deadlines.all()[0].deadline, deadline_datetime)
        self.assertEquals(group2.last_deadline, group2.deadlines.all()[0])
        self.assertEquals(group2.last_deadline.deliveries.count(), 1)
        group2_last_delivery = Delivery.objects.filter(deadline__assignment_group=group2).first()
        self.assertEquals(group2.last_deadline.deliveries.all()[0], group2_last_delivery)
        self.assertTrue(group2_last_delivery.successful)
        self.assertEquals(group2_last_delivery.number, 1)
Esempio n. 7
0
    def test_can_not_invite_someone_that_is_already_in_projectgroup(self):
        periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active() \
            .add_relatedstudents(self.testuser2)
        assignment1builder = periodbuilder.add_assignment(
            'assignment1', students_can_create_groups=True)
        assignment2builder = periodbuilder.add_assignment(
            'assignment2', students_can_create_groups=True)

        assignment1builder.add_group(students=[self.testuser2, self.testuser3])
        group1 = assignment1builder.add_group(students=[self.testuser1]).group
        group2 = assignment2builder.add_group(students=[self.testuser1]).group

        with self.assertRaisesRegexp(
                ValidationError,
                r'^.*The invited student is already in a project group.*$'):
            GroupInvite(group=group1,
                        sent_by=self.testuser1,
                        sent_to=self.testuser2,
                        accepted=True).clean()

        # Ensure we are not affected by having groups in other assignments
        GroupInvite(group=group2,
                    sent_by=self.testuser1,
                    sent_to=self.testuser2,
                    accepted=True).clean()
    def test_invite_email(self):
        group = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_relatedstudents(self.testuser2)\
            .add_assignment('assignment1', students_can_create_groups=True)\
            .add_group(students=[self.testuser1]).group
        invite = group.groupinvite_set.create(
            sent_by=self.testuser1,
            sent_to=self.testuser2)
        self.assertEqual(len(mail.outbox), 0)

        class FakeRequest(object):
            def build_absolute_uri(self, location):
                return 'http://example.com{}'.format(location)

        invite.send_invite_notification(FakeRequest())
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, ['*****@*****.**'])
        self.assertEqual(mail.outbox[0].subject, '[Devilry] Project group invite for duck1010.active.assignment1')
        self.assertIn(
            u'testuser1 invited you to join their project\ngroup for duck1010 assignment1.',
            mail.outbox[0].body)
        self.assertIn(
            'http://example.com{}'.format(reverse('devilry_student_groupinvite_respond',
                kwargs={'invite_id': invite.id})),
            mail.outbox[0].body)
 def test_groupinvite_allowed(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1', students_can_create_groups=True)\
         .add_group(students=[self.testuser])
     groupbuilder.add_deadline_in_x_weeks(weeks=1)
     html = self._getas(groupbuilder.group.id, self.testuser).content
     self.assertTrue(cssExists(html, '#devilry_student_projectgroupoverview_invitebox'))
    def test_update(self):
        periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_admins(self.testuser)

        publishing_time = DateTimeBuilder.now().plus(days=10)
        assignment1builder = periodbuilder.add_assignment('assignment1',
            long_name='Assignment One',
            anonymous=True,
            publishing_time=publishing_time,
            deadline_handling=1,
            max_points=10, # Should not be touched by the update
            passing_grade_min_points=8 # Should not be touched by the update
        )

        new_publishing_time = DateTimeBuilder.now().plus(days=20).replace(second=0, microsecond=0, tzinfo=None)
        response = self._postas(assignment1builder.assignment.id, self.testuser, {
            'long_name': 'Test One',
            'short_name': 'test1',
            'anonymous': '',
            'publishing_time': isoformat_datetime(new_publishing_time),
            'deadline_handling': 0
        })
        self.assertEquals(response.status_code, 302)
        assignment1builder.reload_from_db()
        assignment = assignment1builder.assignment
        self.assertEquals(assignment.long_name, 'Test One')
        self.assertEquals(assignment.short_name, 'test1')
        self.assertFalse(assignment.anonymous)
        self.assertEquals(assignment.publishing_time, new_publishing_time)
        self.assertEquals(assignment.deadline_handling, 0)
        self.assertEquals(assignment.max_points, 10)
        self.assertEquals(assignment.passing_grade_min_points, 8)
Esempio n. 11
0
 def test_convert_multiple_to_delivery(self):
     deadline = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1')\
         .add_group(students=[self.testuser])\
         .add_deadline_x_weeks_ago(weeks=1).deadline
     UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing.txt',
         filecontent=ContentFile('Hello world')
     )
     UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing2.txt',
         filecontent=ContentFile('Hello world 2')
     )
     delivery, files = UploadedDeliveryFile.objects.convert_to_delivery(deadline, self.testuser)
     self.assertEquals(delivery.filemetas.count(), 2)
     self.assertEquals(
         set([f.filename for f in delivery.filemetas.all()]),
         set(['testing.txt', 'testing2.txt']))
     self.assertEquals(
         set([f.get_all_data_as_string() for f in delivery.filemetas.all()]),
         set(['Hello world', 'Hello world 2']))
 def test_convert_multiple_to_delivery(self):
     deadline = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1')\
         .add_group(students=[self.testuser])\
         .add_deadline_x_weeks_ago(weeks=1).deadline
     UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing.txt',
         filecontent=ContentFile('Hello world')
     )
     UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing2.txt',
         filecontent=ContentFile('Hello world 2')
     )
     delivery, files = UploadedDeliveryFile.objects.convert_to_delivery(deadline, self.testuser)
     self.assertEquals(delivery.filemetas.count(), 2)
     self.assertEquals(
         set([f.filename for f in delivery.filemetas.all()]),
         set(['testing.txt', 'testing2.txt']))
     self.assertEquals(
         set([f.get_all_data_as_string() for f in delivery.filemetas.all()]),
         set(['Hello world', 'Hello world 2']))
 def test_set_number_first(self):
     deadline = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1').add_group()\
         .add_deadline_x_weeks_ago(weeks=1).deadline
     delivery = Delivery(deadline=deadline)
     delivery.set_number()
     self.assertEqual(delivery.number, 1)
 def setUp(self):
     self.testuser = UserBuilder('testuser').user
     self.factory = RequestFactory()
     self.periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()
     self.assignmentbuilder = self.periodbuilder.add_assignment('testassignment')
     self.groupbuilder = self.assignmentbuilder.add_group()
     self.groupbuilder.add_deadline_in_x_weeks(weeks=1)
     self.groupbuilder.add_students(self.testuser)
Esempio n. 15
0
 def setUp(self):
     self.admin1 = UserBuilder('admin1').user
     self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_admins(self.admin1)
     self.url = reverse('devilry_gradingsystem_admin_setmaxpoints', kwargs={
         'assignmentid': self.assignmentbuilder.assignment.id,
     })
 def test_create_deadline_opens_assignmentgroup(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group()
     groupbuilder.update(is_open=False)
     groupbuilder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=3))
     groupbuilder.reload_from_db()
     self.assertTrue(groupbuilder.group.is_open)
 def setUp(self):
     self.admin1 = UserBuilder('admin1').user
     self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_admins(self.admin1)
     self.url = reverse('devilry_gradingsystem_admin_setpassing_grade_min_points', kwargs={
         'assignmentid': self.assignmentbuilder.assignment.id,
     })
 def test_create_deadline_changes_assignmentgroup_delivery_status(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group()
     self.assertEquals(groupbuilder.group.delivery_status, 'no-deadlines')
     groupbuilder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=3))
     groupbuilder.reload_from_db()
     self.assertEquals(groupbuilder.group.delivery_status, 'waiting-for-something')
 def test_set_last_deadline_on_group_single(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group()
     self.assertIsNone(groupbuilder.group.last_deadline)
     deadline = groupbuilder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=3))
     groupbuilder.reload_from_db()
     self.assertEquals(groupbuilder.group.last_deadline, deadline)
 def test_filter_admin_has_access_directly_on_assignment(self):
     admin1 = UserBuilder('admin1').user
     periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()
     assignment1 = periodbuilder.add_assignment('assignment1').add_admins(admin1).assignment
     periodbuilder.add_assignment('assignment2')
     qry = Assignment.objects.filter_admin_has_access(admin1)
     self.assertEquals(qry.count(), 1)
     self.assertEquals(qry[0], assignment1)
 def test_points_to_grade_points(self):
     assignment1 = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment(
             'assignment1',
             points_to_grade_mapper='raw-points',
             max_points=10).assignment
     self.assertEquals(assignment1.points_to_grade(0), '0/10')
     self.assertEquals(assignment1.points_to_grade(1), '1/10')
     self.assertEquals(assignment1.points_to_grade(10), '10/10')
 def test_render(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group(students=[self.testuser])
     groupbuilder.add_deadline_in_x_weeks(weeks=1)
     response = self._getas(groupbuilder.group.id, self.testuser)
     self.assertEquals(response.status_code, 200)
     html = response.content
     self.assertEquals(cssGet(html, 'h1').text.strip(), 'Project group')
 def test_only_groupmember_can_invite(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser2)\
         .add_assignment('assignment1',
             students_can_create_groups=True)\
         .add_group(students=[self.testuser1]).group
     with self.assertRaisesRegexp(ValidationError,
             r'^.*The user sending an invite must be a Candiate on the group.*$'):
         GroupInvite(group=group, sent_by=self.testuser2, sent_to=self.testuser3).clean()
 def test_is_last_delivery(self):
     deadlinebuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1')\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)
     delivery1 = deadlinebuilder.add_delivery_x_hours_after_deadline(hours=1).delivery
     delivery2 = deadlinebuilder.add_delivery_x_hours_after_deadline(hours=2).delivery
     self.assertTrue(delivery2.is_last_delivery)
     self.assertFalse(delivery1.is_last_delivery)
 def test_can_not_invite_self(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser1)\
         .add_assignment('assignment1',
             students_can_create_groups=True)\
         .add_group(students=[self.testuser1]).group
     with self.assertRaisesRegexp(ValidationError,
             r'^.*The student is already a member of the group.*$'):
         GroupInvite(group=group, sent_by=self.testuser1, sent_to=self.testuser1).clean()
 def test_is_in_the_future_and_is_in_the_past(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group()
     past_deadline = groupbuilder.add_deadline_x_weeks_ago(weeks=2).deadline
     future_deadline = groupbuilder.add_deadline_in_x_weeks(weeks=2).deadline
     self.assertTrue(future_deadline.is_in_the_future())
     self.assertFalse(future_deadline.is_in_the_past())
     self.assertFalse(past_deadline.is_in_the_future())
     self.assertTrue(past_deadline.is_in_the_past())
 def setUp(self):
     self.testexaminer = UserBuilder('testexaminer').user
     self.deliverybuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
                         points_to_grade_mapper='raw-points',
                         passing_grade_min_points=20,
                         max_points=100) \
         .add_group(examiners=[self.testexaminer])\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery_x_hours_before_deadline(hours=1)
 def test_autocreate_delivery_if_nonelectronic_false(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
             delivery_types=deliverytypes.NON_ELECTRONIC)\
         .add_group()
     deadline = Deadline(
         assignment_group=groupbuilder.group,
         deadline=DateTimeBuilder.now().plus(days=10))
     deadline.save(autocreate_delivery_if_nonelectronic=False)
     self.assertEquals(deadline.deliveries.count(), 0)
Esempio n. 29
0
 def setUp(self):
     assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('testassignment')
     self.deliverybuilder = assignmentbuilder\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery()
     DetektorAssignment.objects.create(
         assignment=assignmentbuilder.assignment)
     self.assignmentparser = AssignmentParser(assignmentbuilder.assignment.id)
 def test_can_not_invite_someone_that_already_has_invite_for_group(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_relatedstudents(self.testuser2)\
         .add_assignment('assignment1',
             students_can_create_groups=True)\
         .add_group(students=[self.testuser1]).group
     GroupInvite(group=group, sent_by=self.testuser1, sent_to=self.testuser2).save()
     with self.assertRaisesRegexp(ValidationError,
             r'^.*The student is already invited to join the group, but they have not responded yet.*$'):
         GroupInvite(group=group, sent_by=self.testuser1, sent_to=self.testuser2).clean()
 def test_only_if_invited(self):
     notalloweduser = UserBuilder('notalloweduser').user
     group = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')\
         .add_group(students=[self.testfromuser]).group
     invite = group.groupinvite_set.create(
         sent_by=self.testfromuser,
         sent_to=self.testtouser)
     response = self._getas(invite.id, notalloweduser)
     self.assertEquals(response.status_code, 404)
 def setUp(self):
     self.testexaminer = UserBuilder('testexaminer').user
     self.deliverybuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
                         points_to_grade_mapper='raw-points',
                         passing_grade_min_points=20,
                         max_points=100) \
         .add_group(examiners=[self.testexaminer])\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery_x_hours_before_deadline(hours=1)
    def test_soft_deadlines_expired_only_owned(self):
        assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_assignment('testassignment',
                            deadline_handling=Assignment.DEADLINEHANDLING_SOFT)
        assignmentbuilder.add_group(students=[UserBuilder('otheruser').user])\
            .add_deadline_x_weeks_ago(weeks=1)

        response = self._get_as('testuser')
        selector = htmls.S(response.content)
        self.assertEquals(selector.count('#objecttableview-table tbody tr'), 0)
    def test_filter_is_examiner(self):
        examiner1 = UserBuilder('examiner1').user
        week1builder = PeriodBuilder.quickadd_ducku_duck1010_active().add_assignment('week1')
        week1builder.add_group().add_examiners(examiner1)

        # Add another group to make sure we do not get false positives
        week1builder.add_group().add_examiners(UserBuilder('examiner2').user)

        qry = Assignment.objects.filter_is_examiner(examiner1)
        self.assertEquals(qry.count(), 1)
        self.assertEquals(qry[0], week1builder.assignment)
 def test_list_single(self):
     currentperiodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()
     week1builder = currentperiodbuilder.add_assignment('week1', 'Week 1')
     week1builder.add_group().add_examiners(self.examiner1)
     response = self._getas('examiner1')
     self.assertEquals(response.status_code, 200)
     html = response.content
     self.assertEquals(len(cssFind(html, '.active-assignment-listing-item')), 1)
     linktag = cssGet(html, 'a.assignment-duck1010.active.week1')
     self.assertEquals(linktag.text.strip(), 'duck1010.active - Week 1')
     self.assertEquals(linktag['href'], '/devilry_examiner/allgroupsoverview/{}/waiting_for_feedback_or_all'.format(week1builder.assignment.id))
Esempio n. 36
0
 def test_can_not_invite_self(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser1) \
         .add_assignment('assignment1',
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*The student is already a member of the group.*$'):
         GroupInvite(group=group,
                     sent_by=self.testuser1,
                     sent_to=self.testuser1).clean()
Esempio n. 37
0
 def test_invited_student_must_be_relatedstudent(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_assignment('assignment1',
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     invite = GroupInvite(group=group,
                          sent_by=self.testuser1,
                          sent_to=self.testuser2)
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*The invited student is not registered on this subject.*$'
     ):
         invite.full_clean()
Esempio n. 38
0
 def test_only_groupmember_can_invite(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1',
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*The user sending an invite must be a Candiate on the group.*$'
     ):
         GroupInvite(group=group,
                     sent_by=self.testuser2,
                     sent_to=self.testuser3).clean()
Esempio n. 39
0
 def test_only_when_allowed_on_assignment(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1',
                         students_can_create_groups=False) \
         .add_group(students=[self.testuser1]).group
     invite = GroupInvite(group=group,
                          sent_by=self.testuser1,
                          sent_to=self.testuser2)
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*This assignment does not allow students to form '
             r'project groups on their own.*$'):
         invite.full_clean()
Esempio n. 40
0
 def test_create_sanity(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1',
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     before = datetime.now()
     invite = GroupInvite(group=group,
                          sent_by=self.testuser1,
                          sent_to=self.testuser2)
     invite.full_clean()
     invite.save()
     after = datetime.now()
     self.assertTrue(invite.sent_datetime >= before
                     and invite.sent_datetime <= after)
Esempio n. 41
0
 def test_students_can_not_create_groups_after(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1',
                         students_can_not_create_groups_after=DateTimeBuilder.now().minus(days=1),
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     invite = GroupInvite(group=group,
                          sent_by=self.testuser1,
                          sent_to=self.testuser2)
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*Creating project groups without administrator approval is '
             r'not allowed on this assignment anymore.*$'):
         invite.full_clean()
Esempio n. 42
0
 def test_delete(self):
     deadline = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1')\
         .add_group(students=[self.testuser])\
         .add_deadline_x_weeks_ago(weeks=1).deadline
     uploadedfile = UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing2.txt',
         filecontent=ContentFile('Hello world 2')
     )
     path = uploadedfile.uploaded_file.file.name
     self.assertTrue(exists(path))
     UploadedDeliveryFile.objects.get_queryset().all().delete_objects_and_files()
     self.assertEquals(UploadedDeliveryFile.objects.count(), 0)
     self.assertFalse(exists(path))
Esempio n. 43
0
 def setUp(self):
     self.admin1 = UserBuilder('admin1').user
     self.myregistry = GradingSystemPluginRegistry()
     self.myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
             grading_system_plugin_id=MockPointsPluginApi.id,
             max_points=100,
             points_to_grade_mapper='custom-table'
         )\
         .add_admins(self.admin1)
     self.url = reverse('devilry_gradingsystem_admin_setup_custom_table',
                        kwargs={
                            'assignmentid':
                            self.assignmentbuilder.assignment.id,
                        })
Esempio n. 44
0
 def test_respond_accept_add_candidate(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1', students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     invite = GroupInvite(group=group,
                          sent_by=self.testuser1,
                          sent_to=self.testuser2)
     invite.save()
     self.assertEquals(AssignmentGroup.objects.count(), 1)
     invite.respond(accepted=True)
     self.assertTrue(invite.accepted)
     self.assertTrue(group.candidates.count(), 2)
     self.assertEquals(set([c.student for c in group.candidates.all()]),
                       set([self.testuser1, self.testuser2]))
     self.assertEquals(AssignmentGroup.objects.count(), 1)
Esempio n. 45
0
 def test_can_not_invite_someone_that_already_has_invite_for_group(self):
     group = PeriodBuilder.quickadd_ducku_duck1010_active() \
         .add_relatedstudents(self.testuser2) \
         .add_assignment('assignment1',
                         students_can_create_groups=True) \
         .add_group(students=[self.testuser1]).group
     GroupInvite(group=group,
                 sent_by=self.testuser1,
                 sent_to=self.testuser2).save()
     with self.assertRaisesRegexp(
             ValidationError,
             r'^.*The student is already invited to join the group, '
             r'but they have not responded yet.*$'):
         GroupInvite(group=group,
                     sent_by=self.testuser1,
                     sent_to=self.testuser2).clean()
Esempio n. 46
0
    def test_respond_reject(self):
        group = PeriodBuilder.quickadd_ducku_duck1010_active() \
            .add_relatedstudents(self.testuser2) \
            .add_assignment('assignment1', students_can_create_groups=True) \
            .add_group(students=[self.testuser1]).group
        invite = GroupInvite(group=group,
                             sent_by=self.testuser1,
                             sent_to=self.testuser2)
        invite.save()
        self.assertIsNone(invite.accepted)

        before = datetime.now()
        invite.respond(accepted=False)
        after = datetime.now()
        self.assertFalse(invite.accepted)
        self.assertTrue(invite.responded_datetime >= before
                        and invite.responded_datetime <= after)
        self.assertTrue(group.candidates.count(), 1)
Esempio n. 47
0
    def test_rejected_email(self):
        group = PeriodBuilder.quickadd_ducku_duck1010_active() \
            .add_relatedstudents(self.testuser2) \
            .add_assignment('assignment1', students_can_create_groups=True) \
            .add_group(students=[self.testuser1]).group
        invite = group.groupinvite_set.create(sent_by=self.testuser1,
                                              sent_to=self.testuser2)

        self.assertEqual(len(mail.outbox), 0)
        invite.respond(accepted=False)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, ['*****@*****.**'])
        self.assertEqual(
            mail.outbox[0].subject,
            '[Devilry] testuser2 rejected your project group invite')
        self.assertIn(
            u'testuser2 rejected the invite to join your project\ngroup for duck1010 assignment1',
            mail.outbox[0].body)
Esempio n. 48
0
 def test_convert_to_delivery(self):
     deadline = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('week1')\
         .add_group(students=[self.testuser])\
         .add_deadline_x_weeks_ago(weeks=1).deadline
     UploadedDeliveryFile.objects.create_with_file(
         user=self.testuser,
         deadline=deadline,
         filename='testing.txt',
         filecontent=ContentFile('Hello world')
     )
     delivery, files = UploadedDeliveryFile.objects.convert_to_delivery(deadline, self.testuser)
     self.assertIsNotNone(delivery.id)
     self.assertEquals(delivery.deadline, deadline)
     self.assertEquals(delivery.delivered_by, deadline.assignment_group.candidates.all()[0])
     self.assertEquals(delivery.delivered_by.relatedstudent.user, self.testuser)
     self.assertEquals(delivery.filemetas.count(), 1)
     filemeta = delivery.filemetas.all()[0]
     self.assertEquals(filemeta.filename, 'testing.txt')
     self.assertEquals(filemeta.get_all_data_as_string(), 'Hello world')
Esempio n. 49
0
    def test_send_invite_to_choices_queryset(self):
        UserBuilder('ignoreduser')
        alreadyingroupuser1 = UserBuilder('alreadyingroupuser1').user
        alreadyingroupuser2 = UserBuilder('alreadyingroupuser2').user
        hasinviteuser = UserBuilder('hasinviteuser').user
        matchuser1 = UserBuilder('matchuser1').user
        matchuser2 = UserBuilder('matchuser2').user

        group = PeriodBuilder.quickadd_ducku_duck1010_active() \
            .add_relatedstudents(
            alreadyingroupuser1, alreadyingroupuser2, hasinviteuser,
            matchuser1, matchuser2) \
            .add_assignment('assignment1', students_can_create_groups=True) \
            .add_group(students=[alreadyingroupuser1, alreadyingroupuser2]).group
        group.groupinvite_set.create(sent_by=alreadyingroupuser1,
                                     sent_to=hasinviteuser)

        can_invite_users = set(
            GroupInvite.send_invite_to_choices_queryset(group))
        self.assertEquals(can_invite_users, set([matchuser1, matchuser2]))
Esempio n. 50
0
 def setUp(self):
     self.testuser = UserBuilder('testuser').user
     self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('testassignment')
 def setUp(self):
     self.periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()
     self.assignment = self.periodbuilder.add_assignment(
         'assignment', max_points=100).assignment
 def setUp(self):
     self.assignment = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment').assignment
     self.point_to_grade_map = PointToGradeMap.objects.create(
         assignment=self.assignment)
Esempio n. 53
0
 def setUp(self):
     self.deliverybuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('testassignment')\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery()