예제 #1
0
파일: test_rules.py 프로젝트: saty9/allez
 def setUp(self):
     self.c = Client()
     self.competition = PreAddedCompetitionOfSize(entries__num_of_entries=8)
     self.org = self.competition.organisation
     self.manager = ManagerFactory(organisation=self.org).user
     self.dt = DTFactory(organisation=self.org).user
     self.applicant = OrgMemberFactory(organisation=self.org).user
     org = OrganisationFactory()
     self.wrong_org_manager = ManagerFactory(organisation=org).user
예제 #2
0
 def test_join_organisation_already_applied(self):
     applicant = UserFactory()
     user = DTFactory(organisation=self.organisation).user
     self.c.force_login(user)
     out = self.c.post(self.target, {'type': 'join_request',
                                     'user_id': applicant.id})
     self.assertJSONEqual(out.content, {'success': False,
                                        'reason': 'InsufficientPermissions'})
     self.assertEqual(applicant.organisationmembership_set.count(), 0)
예제 #3
0
 def test_accept_application_unauthorised(self):
     applicant = OrgMemberFactory(organisation=self.organisation)
     for user in [applicant.user, DTFactory(organisation=self.organisation).user]:
         self.c.force_login(user)
         out = self.c.post(self.target, {'type': 'accept_application',
                                         'user_id': applicant.user.id})
         self.assertJSONEqual(out.content, {'success': False,
                                            'reason': 'InsufficientPermissions'})
         applicant.refresh_from_db()
         self.assertEqual(applicant.state, OrganisationMembership.APPLICANT)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
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'])