當前位置: 首頁>>代碼示例>>Python>>正文


Python corebuilder.PeriodBuilder類代碼示例

本文整理匯總了Python中devilry_developer.testhelpers.corebuilder.PeriodBuilder的典型用法代碼示例。如果您正苦於以下問題:Python PeriodBuilder類的具體用法?Python PeriodBuilder怎麽用?Python PeriodBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PeriodBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_smart_create_non_electronic

    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)
        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)
        self.assertEquals(group2.last_deadline.deliveries.all()[0], group2.last_delivery)
        self.assertTrue(group2.last_delivery.successful)
        self.assertEquals(group2.last_delivery.number, 1)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:32,代碼來源:deadline.py

示例2: test_invite_email

    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, ['[email protected]'])
        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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:25,代碼來源:groupinvite.py

示例3: test_set_last_deadline_on_group_single

 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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:8,代碼來源:deadline.py

示例4: test_create_deadline_changes_assignmentgroup_delivery_status

 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')
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:8,代碼來源:deadline.py

示例5: test_create_deadline_opens_assignmentgroup

 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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:8,代碼來源:deadline.py

示例6: test_filter_admin_has_access_directly_on_assignment

 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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:8,代碼來源:assignment.py

示例7: test_points_to_grade_points

 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')
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:8,代碼來源:assignment.py

示例8: test_only_groupmember_can_invite

 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()
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:9,代碼來源:groupinvite.py

示例9: test_can_not_invite_self

 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()
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:9,代碼來源:groupinvite.py

示例10: test_autocreate_delivery_if_nonelectronic_false

 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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:10,代碼來源:deadline.py

示例11: test_can_not_invite_someone_that_already_has_invite_for_group

 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()
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:10,代碼來源:groupinvite.py

示例12: test_autocreate_delivery_if_nonelectronic

 def test_autocreate_delivery_if_nonelectronic(self):
     groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
             delivery_types=deliverytypes.NON_ELECTRONIC)\
         .add_group()
     deadline = groupbuilder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=10))
     self.assertEquals(deadline.deliveries.count(), 1)
     self.assertTrue(deadline.deliveries.all()[0].successful)
     groupbuilder.reload_from_db()
     self.assertEquals(groupbuilder.group.last_delivery, deadline.deliveries.all()[0])
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:10,代碼來源:deadline.py

示例13: test_filter_is_examiner

    def test_filter_is_examiner(self):
        examiner1 = UserBuilder('examiner1').user
        week1builder = PeriodBuilder.quickadd_ducku_duck1010_active().add_assignment('week1')
        group1builder = 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)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:11,代碼來源:assignment.py

示例14: test_set_last_deadline_on_group_merge

 def test_set_last_deadline_on_group_merge(self):
     assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')
     group1builder = assignmentbuilder.add_group()
     group2builder = assignmentbuilder.add_group()
     deadline2 = group2builder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=10))
     deadline3 = group1builder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=15))
     deadline1 = group1builder.group.deadlines.create(deadline=DateTimeBuilder.now().plus(days=5))
     group2builder.group.merge_into(group1builder.group)
     group1builder.reload_from_db()
     self.assertEquals(group1builder.group.last_deadline, deadline3)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:11,代碼來源:deadline.py

示例15: test_smart_create_no_text

 def test_smart_create_no_text(self):
     assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1')
     group1builder = assignmentbuilder.add_group()
     deadline_datetime = Deadline.reduce_datetime_precision(DateTimeBuilder.now().plus(days=10))
     Deadline.objects.smart_create(
         assignmentbuilder.assignment.assignmentgroups.all(),
         deadline_datetime=deadline_datetime)
     group1builder.reload_from_db()
     self.assertEquals(group1builder.group.last_deadline.deadline, deadline_datetime)
     self.assertEquals(group1builder.group.last_deadline.text, None)
開發者ID:unioslo,項目名稱:devilry-django,代碼行數:11,代碼來源:deadline.py


注:本文中的devilry_developer.testhelpers.corebuilder.PeriodBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。