Пример #1
0
  def testInviteOrgAdmin(self):
    # test GET
    self.data.createOrgAdmin(self.org)
    url = '/gsoc/invite/org_admin/' + self.org.key().name()
    response = self.client.get(url)
    self.assertInviteTemplatesUsed(response)

    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_user = other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()

    # test POST
    override = {'link_id': other_user.link_id, 'status': 'pending',
                'role': 'org_admin', 'user': other_user, 'group': self.org,
                'type': 'Invitation'}
    response, properties = self.modelPost(url, Request, override)

    invitation = Request.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)

    invitation.delete()
    override['link_id'] = '*****@*****.**'
    response, properties = self.modelPost(url, Request, override)

    invitation = Request.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)
Пример #2
0
  def createRequest(self):
    """Creates and returns an accepted invitation for the current user.
    """
    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()
    request = other_data.createMentorRequest(self.org)

    return (other_data, request)
Пример #3
0
    def createRequest(self):
        """Creates and returns an accepted invitation for the current user.
    """
        # create other user to send invite to
        other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data.createOtherUser('*****@*****.**')
        other_data.createProfile()
        request = other_data.createMentorRequest(self.org)

        return (other_data, request)
Пример #4
0
 def testAUserNotLoggedInIsRedirectedToLoginPage(self):
     """Tests that a user who is not logged in and trying to access its profile
 is redirected to a login page.
 """
     profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
     profile_helper.createOtherUser('*****@*****.**')
     profile_helper.createProfile()
     import os
     current_logged_in_account = os.environ.get('USER_EMAIL', None)
     try:
         os.environ['USER_EMAIL'] = ''
         url = '/gsoc/profile/admin/' + profile_helper.profile.key().name()
         response = self.get(url)
         self.assertResponseRedirect(response)
         expected_redirect_url = 'https://www.google.com/accounts/Login?'+\
             'continue=http%3A//Foo%3A8080'+url
         actual_redirect_url = response.get('location', None)
         self.assertEqual(expected_redirect_url, actual_redirect_url)
     finally:
         if current_logged_in_account is None:
             del os.environ['USER_EMAIL']
         else:
             os.environ['USER_EMAIL'] = current_logged_in_account
Пример #5
0
 def testAUserNotLoggedInIsRedirectedToLoginPage(self):
   """Tests that a user who is not logged in and trying to access its profile
   is redirected to a login page.
   """
   profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
   profile_helper.createOtherUser('*****@*****.**')
   profile_helper.createProfile()
   import os
   current_logged_in_account = os.environ.get('USER_EMAIL', None)
   try:
     os.environ['USER_EMAIL'] = ''
     url = '/gsoc/profile/admin/' + profile_helper.profile.key().name()
     response = self.get(url)
     self.assertResponseRedirect(response)
     expected_redirect_url = 'https://www.google.com/accounts/Login?'+\
         'continue=http%3A//Foo%3A8080'+url
     actual_redirect_url = response.get('location', None)
     self.assertEqual(expected_redirect_url, actual_redirect_url)
   finally:
     if current_logged_in_account is None:
       del os.environ['USER_EMAIL']
     else:
       os.environ['USER_EMAIL'] = current_logged_in_account
Пример #6
0
  def testInviteOrgAdmin(self):
    # test GET
    self.data.createOrgAdmin(self.org)
    url = '/gsoc/invite/org_admin/' + self.org.key().name()
    response = self.get(url)
    self.assertInviteTemplatesUsed(response)

    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()
    other_data.notificationSettings(new_invites=True)
    other_user = other_data.user

    # test POST
    override = {
        'link_id': other_user.link_id, 'status': 'pending',
        'role': 'org_admin', 'user': other_user, 'org': self.org,
        'type': 'Invitation',
        'parent': other_user,
    }
    response, properties = self.modelPost(url, GSoCRequest, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

    invitation = GSoCRequest.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)

    other_data2 = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data2.createOtherUser('*****@*****.**')
    other_data2.createProfile()
    other_data2.notificationSettings()

    invitation.delete()
    override['link_id'] = '[email protected], [email protected]'
    other_data.notificationSettings()
    response, properties = self.modelPost(url, GSoCRequest, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

    invitations = GSoCRequest.all().fetch(2)
    self.assertEqual(2, len(invitations))
    invitation = invitations[0]
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)
    properties['user'] = other_data2.user
    properties['parent'] = other_data2.user
    self.assertPropertiesEqual(properties, invitations[1])

    # test withdraw/resubmit invite
    url = '/gsoc/invitation/%s/%s/%s' % (
	self.gsoc.key().name(),
	invitation.parent_key().name(),
	invitation.key().id())

    other_data.notificationSettings(invite_handled=True)

    postdata = {'action': 'Withdraw'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invite = GSoCRequest.all().get()
    self.assertEqual('withdrawn', invite.status)
    self.assertEmailSent(to=other_data.profile.email, n=2)

    # test that you can resubmit
    postdata = {'action': 'Resubmit'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invite = GSoCRequest.all().get()
    self.assertEqual('pending', invite.status)
    self.assertEmailSent(to=other_data.profile.email, n=3)
Пример #7
0
    def testInviteOrgAdmin(self):
        # test GET
        self.data.createOrgAdmin(self.org)
        url = '/gsoc/invite/org_admin/' + self.org.key().name()
        response = self.get(url)
        self.assertInviteTemplatesUsed(response)

        # create other user to send invite to
        other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data.createOtherUser('*****@*****.**')
        other_data.createProfile()
        other_data.notificationSettings(new_invites=True)
        other_user = other_data.user

        # test POST
        override = {
            'link_id': other_user.link_id,
            'status': 'pending',
            'role': 'org_admin',
            'user': other_user,
            'org': self.org,
            'type': 'Invitation',
            'parent': other_user,
        }
        response, properties = self.modelPost(url, GSoCRequest, override)
        self.assertEmailSent(to=other_data.profile.email, n=1)

        invitation = GSoCRequest.all().get()
        properties.pop('link_id')
        self.assertPropertiesEqual(properties, invitation)

        other_data2 = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data2.createOtherUser('*****@*****.**')
        other_data2.createProfile()
        other_data2.notificationSettings()

        invitation.delete()
        override[
            'link_id'] = '[email protected], [email protected]'
        other_data.notificationSettings()
        response, properties = self.modelPost(url, GSoCRequest, override)
        self.assertEmailSent(to=other_data.profile.email, n=1)

        invitations = GSoCRequest.all().fetch(2)
        self.assertEqual(2, len(invitations))
        invitation = invitations[0]
        properties.pop('link_id')
        self.assertPropertiesEqual(properties, invitation)
        properties['user'] = other_data2.user
        properties['parent'] = other_data2.user
        self.assertPropertiesEqual(properties, invitations[1])

        # test withdraw/resubmit invite
        url = '/gsoc/invitation/%s/%s/%s' % (self.gsoc.key().name(),
                                             invitation.parent_key().name(),
                                             invitation.key().id())

        other_data.notificationSettings(invite_handled=True)

        postdata = {'action': 'Withdraw'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        invite = GSoCRequest.all().get()
        self.assertEqual('withdrawn', invite.status)
        self.assertEmailSent(to=other_data.profile.email, n=2)

        # test that you can resubmit
        postdata = {'action': 'Resubmit'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        invite = GSoCRequest.all().get()
        self.assertEqual('pending', invite.status)
        self.assertEmailSent(to=other_data.profile.email, n=3)