def test_competitor_autocomplete_unauthorised(self): user = OrgMemberFactory(organisation=self.organisation).user competition = BaseCompetitionFactory(organisation=self.organisation) for _ in range(8): EntryFactory(organisation=self.organisation, competition=competition) expected = self.organisation.competitor_set.first() self.c.force_login(user) out = self.c.get(self.target, {'type': 'autocomplete_competitor', 'name': expected.name[:5]}) self.assertJSONEqual(out.content, {'success': False, 'reason': 'InsufficientPermissions'})
def test_competitor_limit_response_length(self): user = DTFactory(organisation=self.organisation).user competition = BaseCompetitionFactory(organisation=self.organisation) for _ in range(MAX_AUTOCOMPLETE_RESPONSES + 1): EntryFactory(organisation=self.organisation, competition=competition) self.organisation.competitor_set.update(name="Roger Rabbit") self.c.force_login(user) out = self.c.get(self.target, {'type': 'autocomplete_competitor', 'name': 'roger'}) result = json.loads(out.content) self.assertEqual(len(result['competitors']), MAX_AUTOCOMPLETE_RESPONSES)
def test_competitor_autocomplete_short_string(self): user = DTFactory(organisation=self.organisation).user competition = BaseCompetitionFactory(organisation=self.organisation) for _ in range(8): EntryFactory(organisation=self.organisation, competition=competition) expected = self.organisation.competitor_set.first() self.c.force_login(user) out = self.c.get(self.target, {'type': 'autocomplete_competitor', 'name': expected.name[0:2]}) result = json.loads(out.content) self.assertEqual(len(result['competitors']), 0)
def test_competitor_autocomplete(self): user = DTFactory(organisation=self.organisation).user competition = BaseCompetitionFactory(organisation=self.organisation) for _ in range(8): EntryFactory(organisation=self.organisation, competition=competition) expected = self.organisation.competitor_set.first() self.c.force_login(user) out = self.c.get(self.target, {'type': 'autocomplete_competitor', 'name': expected.name[0:5]}) result = json.loads(out.content) expected_values = {'name': expected.name, 'license_number': expected.license_number, 'club_name': expected.entry_set.latest().club.name} self.assertIn(expected_values, result['competitors'])
def test_check_in_many_entries(self): c = BaseCompetitionFactory(organisation=self.organisation) EntryFactory.create_batch(5, competition=c) target = reverse('ui/check_in', args=[self.organisation.slug, c.id]) self.three_perm_check(target, self.manager, 302, 403, 200)
def test_check_in_no_entries(self): c = BaseCompetitionFactory(organisation=self.organisation) target = reverse('ui/check_in', args=[self.organisation.slug, c.id]) self.three_perm_check(target, self.manager, 302, 403, 200)