예제 #1
0
 def test_join_organisation_manager(self):
     applicant = UserFactory()
     self.c.force_login(self.manager)
     out = self.c.post(self.target, {'type': 'join_request',
                                     'user_id': applicant.id})
     self.assertJSONEqual(out.content, {'success': True})
     application = applicant.organisationmembership_set.get(organisation=self.organisation)
     self.assertEqual(application.state, OrganisationMembership.DT)
예제 #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_organisation_creation(self):
     c = Client()
     target = reverse('ui/organisation/create')
     params = {"name": "name", "email": "*****@*****.**", "slug": "orgslug"}
     response = c.post(target, params)
     self.assertRedirects(response, reverse("login") + '?next=' + target)
     user = UserFactory()
     c.force_login(user)
     response = c.post(target, params)
     self.assertRedirects(
         response,
         reverse('ui/org/competitions', kwargs={'org_slug': "orgslug"}))
     org_query = Organisation.objects.filter(**params)
     self.assertTrue(org_query.exists())
     self.assertEqual(c.session["org_id"], org_query.first().id)
예제 #4
0
파일: ui_test_case.py 프로젝트: saty9/allez
    def three_perm_check(self, target, authorized_user, not_logged_in, logged_in, authorised):
        """

        :param target: target url to request
        :param authorized_user: user that has permissions to access page
        :param not_logged_in: status code expected by not logged in user
        :param logged_in: status code expected by logged in user
        :param authorised: status code expected by an authorised user
        """
        c = Client()
        response = c.get(target)
        self.assertEqual(response.status_code, not_logged_in)
        c.force_login(UserFactory())
        response = c.get(target)
        self.assertEqual(response.status_code, logged_in)
        c.force_login(authorized_user)
        response = c.get(target)
        self.assertEqual(response.status_code, authorised)
예제 #5
0
 def test_organisation_list(self):
     user = UserFactory()
     target = reverse('ui/organisation/list')
     self.three_perm_check(target, user, 200, 200, 200)