本文整理汇总了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)
示例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)
示例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)
示例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')
示例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)
示例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)
示例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')
示例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()
示例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()
示例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)
示例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()
示例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])
示例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)
示例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)
示例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)