def test_regions_admin(self): contest = Contest.objects.get() contest.controller_name = \ 'oioioi.oi.controllers.OIOnsiteContestController' contest.save() r = Region(short_name='waw', name='Warszawa', contest=contest) r.save() self.client.login(username='******') url = reverse('oioioiadmin:oi_region_changelist') response = self.client.get(url) elements_to_find = ['Short name', 'Name', 'waw', 'Warszawa'] for element in elements_to_find: self.assertIn(element, response.content) url = reverse('oioioiadmin:oi_region_change', args=(r.id,)) response = self.client.get(url) elements_to_find = ['Change region', 'waw', 'Warszawa'] for element in elements_to_find: self.assertIn(element, response.content) url = reverse('oioioiadmin:oi_region_delete', args=(r.id,)) response = self.client.post(url, {'post': 'yes'}) self.assertEqual(Region.objects.count(), 0)
def test_participants_import(self): contest = Contest.objects.get() contest.controller_name = \ 'oioioi.oi.controllers.OIOnsiteContestController' contest.save() r = Region(short_name='waw', name='Warszawa', contest=contest) r.save() filename = os.path.join(os.path.dirname(__file__), 'files', 'onsite_participants.csv') manager = import_onsite_participants.Command() manager.run_from_argv(['manage.py', 'import_onsite_participants', str(contest.id), filename]) self.assertEqual(Participant.objects.count(), 3) self.assertEqual(OIOnsiteRegistration.objects.count(), 3)
def test_participants_import(self): contest = Contest.objects.get() r = Region(short_name='waw', name='Warszawa', contest=contest) r.save() filename = os.path.join(os.path.dirname(__file__), 'files', 'onsite_participants.csv') manager = import_onsite_participants.Command() manager.run_from_argv(['manage.py', 'import_onsite_participants', str(contest.id), filename]) self.assertEqual(Participant.objects.count(), 3) self.assertEqual(OIOnsiteRegistration.objects.count(), 3) p = Participant.objects.get(pk=1) self.assertEqual(p.status, 'ACTIVE') self.assertEqual(force_unicode(p.registration_model), '1/waw/1')
def test_participants_import(self): contest = Contest.objects.get() r = Region(short_name='waw', name='Warszawa', contest=contest) r.save() filename = os.path.join(os.path.dirname(__file__), 'files', 'onsite_participants.csv') manager = import_onsite_participants.Command() manager.run_from_argv([ 'manage.py', 'import_onsite_participants', str(contest.id), filename ]) self.assertEqual(Participant.objects.count(), 3) self.assertEqual(OIOnsiteRegistration.objects.count(), 3) p = Participant.objects.get(pk=1) self.assertEqual(p.status, 'ACTIVE') self.assertEqual(force_unicode(p.registration_model), '1/waw/1')
def test_regions_admin(self): contest = Contest.objects.get() r = Region(short_name='waw', name='Warszawa', contest=contest) r.save() self.client.login(username='******') url = reverse('oioioiadmin:oi_region_changelist') response = self.client.get(url) elements_to_find = ['Short name', 'Name', 'waw', 'Warszawa'] for element in elements_to_find: self.assertIn(element, response.content) url = reverse('oioioiadmin:oi_region_change', args=(r.id, )) response = self.client.get(url) elements_to_find = ['Change region', 'waw', 'Warszawa'] for element in elements_to_find: self.assertIn(element, response.content) url = reverse('oioioiadmin:oi_region_delete', args=(r.id, )) self.client.post(url, {'post': 'yes'}) self.assertEqual(Region.objects.count(), 0)