本文整理汇总了Python中oioioi.participants.models.Participant类的典型用法代码示例。如果您正苦于以下问题:Python Participant类的具体用法?Python Participant怎么用?Python Participant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Participant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_both_hands_cascading_on_registration_delete
def test_both_hands_cascading_on_registration_delete(self):
def _assert_equals_len(expectedLen=None):
self.assertEquals(Participant.objects.count(),
TestRegistration.objects.count())
if expectedLen:
self.assertEquals(Participant.objects.count(), expectedLen)
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.ParticipantsContestController'
contest.save()
reg = []
for user in User.objects.all():
p = Participant(contest=contest, user=user)
p.save()
r = TestRegistration(participant=p, name='trolololo')
r.save()
reg.append(r)
_assert_equals_len(len(reg))
reg[0].delete()
_assert_equals_len(len(reg) - 1)
reg[1].participant.delete()
_assert_equals_len(len(reg) - 2)
reg = TestRegistration.objects.filter(name='trolololo').delete()
_assert_equals_len(0)
示例2: test_missing_registration_model
def test_missing_registration_model(self):
contest = Contest.objects.get()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
self.assertRaises(ObjectDoesNotExist,
lambda: getattr(p, 'registration_model'))
示例3: test_contest_info
def test_contest_info(self):
contest = Contest.objects.get()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
OpenRegistration(participant_id=p.id, **self.reg_data).save()
url = reverse('contest_info', kwargs={'contest_id': contest.id})
data = self.client.get(url).json()
self.assertEqual(data['users_count'], 1)
示例4: test_making_complaint
def test_making_complaint(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.oi.controllers.OIOnsiteContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='ACTIVE')
p.save()
with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
self.client.login(username='test_user')
response = self.client.post(reverse('add_complaint',
kwargs={'contest_id': contest.id}),
{'complaint': "I am innocent! It is your fault!"}, follow=True)
self.assertEqual(response.status_code, 403)
cconfig = ComplaintsConfig(contest=contest, enabled=True,
start_date=datetime(2012, 8, 10, tzinfo=utc),
end_date=datetime(2012, 8, 12, tzinfo=utc))
cconfig.save()
with fake_time(datetime(2012, 8, 9, tzinfo=utc)):
response = self.client.get(reverse('add_complaint',
kwargs={'contest_id': contest.id}))
self.assertEqual(response.status_code, 403)
with fake_time(datetime(2012, 8, 13, tzinfo=utc)):
response = self.client.get(reverse('add_complaint',
kwargs={'contest_id': contest.id}))
self.assertEqual(response.status_code, 403)
with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
response = self.client.post(reverse('add_complaint',
kwargs={'contest_id': contest.id}),
{'complaint': "I am innocent! It is your fault!"}, follow=True)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "has been sent")
jurym = mail.outbox[0].message()
userm = mail.outbox[1].message()
del mail.outbox
# Header class doesn't offer 'in' operator
self.assertEqual("[oioioi-complaints] Complaint: Test User (test_user)",
jurym['Subject'])
self.assertEqual("[oioioi-complaints] Complaint: Test User (test_user)",
userm['Subject'])
self.assertEquals("[email protected]", jurym['To'])
self.assertEquals("[email protected]", userm['To'])
self.assertEquals(jurym['Message-ID'], userm['References'])
self.assertEquals(userm['Message-ID'], jurym['References'])
self.assertIn("your fault!", jurym.as_string())
self.assertIn("your fault!", userm.as_string())
示例5: test_participants_accounts_menu
def test_participants_accounts_menu(self):
contest = Contest.objects.get()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
self.assertTrue(self.client.login(username='test_user'))
url = reverse('default_contest_view',
kwargs={'contest_id': contest.id})
response = self.client.get(url, follow=True)
self.assertNotContains(response, 'Register to the contest')
self.assertNotContains(response, 'Edit contest registration')
示例6: test_user_info_page
def test_user_info_page(self):
contest = Contest.objects.get()
contest.controller_name = \
"oioioi.participants.tests.ParticipantsContestController"
contest.save()
user = User.objects.get(pk=1001)
p = Participant(contest=contest, user=user)
p.save()
url = reverse('user_info', kwargs={'contest_id': contest.id,
'user_id': user.id})
self.client.login(username='test_admin')
response = self.client.get(url)
self.assertIn('<h4>Participant info:</h4>', response.content)
示例7: test_participants_accounts_menu
def test_participants_accounts_menu(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.oi.controllers.OIOnsiteContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
self.client.login(username='test_user')
response = self.client.get('/c/%s/' % (contest.id,), follow=True)
self.assertNotIn('Register to the contest', response.content)
self.assertNotIn('Edit contest registration', response.content)
示例8: test_participants_accounts_menu
def test_participants_accounts_menu(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.ParticipantsContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
self.client.login(username='test_user')
url = reverse('default_contest_view', kwargs={'contest_id': contest.id})
response = self.client.get(url, follow=True)
self.assertNotIn('Register to the contest', response.content)
self.assertIn('Edit contest registration', response.content)
示例9: test_onsite_user_info_page
def test_onsite_user_info_page(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.OnsiteContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
reg = OnsiteRegistration(participant=p, number=3, local_number=5)
reg.save()
self.assertTrue(self.client.login(username='test_admin'))
url = reverse('user_info', kwargs={'contest_id': contest.id,
'user_id': user.id})
response = self.client.get(url)
self.assertContains(response, '<h4>OI info:</h4>')
示例10: test_ranking_access
def test_ranking_access(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.oi.controllers.OIContestController'
contest.save()
round = contest.round_set.get()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
url = reverse('default_ranking', kwargs={'contest_id': contest.id})
with fake_time(round.results_date + timedelta(days=1)):
self.client.login(username='test_user')
response = self.client.get(url)
self.assertContains(response, "No rankings available.")
self.client.login(username='test_admin')
response = self.client.get(url)
self.assertContains(response, '>Test User</a>')
示例11: test_noadmin_admin_visibility
def test_noadmin_admin_visibility(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.NoAdminParticipantsContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user)
p.save()
url = reverse('oioioiadmin:participants_participant_changelist')
self.client.login(username='test_user')
check_not_accessible(self, url)
self.client.login(username='test_admin')
check_not_accessible(self, url)
self.client.login(username='test_contest_admin')
check_not_accessible(self, url)
示例12: test_participants_unregister
def test_participants_unregister(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.ParticipantsContestController'
contest.save()
url = reverse('participants_unregister',
kwargs={'contest_id': contest.id})
self.client.login(username='test_user')
response = self.client.post(url, {'post': 'yes'})
self.assertEqual(403, response.status_code)
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
self.assertEqual(Participant.objects.count(), 1)
response = self.client.post(url, {'post': 'yes'})
self.assertEqual(403, response.status_code)
self.assertEqual(Participant.objects.count(), 1)
示例13: test_participants_contest_access
def test_participants_contest_access(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.ParticipantsContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
self.client.login(username='test_user2')
response = self.client.get('/c/%s/' % (contest.id,), follow=True)
self.assertEqual(403, response.status_code)
self.client.login(username='test_user')
response = self.client.get('/c/%s/' % (contest.id,), follow=True)
self.assertEqual(403, response.status_code)
p.status = 'ACTIVE'
p.save()
self.client.login(username='test_user')
response = self.client.get('/c/%s/' % (contest.id,), follow=True)
self.assertEqual(200, response.status_code)
示例14: test_contest_access
def test_contest_access(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.oi.controllers.OIContestController'
contest.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
url = reverse('default_contest_view',
kwargs={'contest_id': contest.id})
self.client.login(username='test_user2')
response = self.client.get(url, follow=True)
self.assertEqual(200, response.status_code)
self.client.login(username='test_user')
response = self.client.get(url, follow=True)
self.assertEqual(200, response.status_code)
p.status = 'ACTIVE'
p.save()
self.client.login(username='test_user')
response = self.client.get(url, follow=True)
self.assertEqual(200, response.status_code)
示例15: test_submit_permissions
def test_submit_permissions(self):
contest = Contest.objects.get()
contest.controller_name = \
'oioioi.participants.tests.ParticipantsContestController'
contest.save()
round = Round.objects.get(pk=1)
problem_instance = ProblemInstance.objects.get(pk=1)
self.assertTrue(problem_instance.round == round)
round.start_date = datetime(2012, 7, 31, tzinfo=utc)
round.end_date = datetime(2012, 8, 5, tzinfo=utc)
round.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=utc)):
self.client.login(username='test_user2')
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
self.client.login(username='test_user')
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
p.status = 'ACTIVE'
p.save()
self.client.login(username='test_user')
response = self.submit_file(contest, problem_instance)
self._assertSubmitted(contest, response)