Example #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)
Example #2
0
  def _requestQuery(self, organization):
    """Returns a query to retrieve a Request for this user.
    """
    if isinstance(organization, db.Model):
      organization = organization.key()

    from soc.models.request import Request
    query = Request.all()
    query.filter('user', self.user)
    query.filter('org', organization)

    return query
Example #3
0
  def testRequestMentor(self):
    # test GET
    self.data.createProfile()
    url = '/gsoc/request/' + self.org.key().name()
    response = self.client.get(url)
    self.assertRequestTemplatesUsed(response)

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

    request = Request.all().get()
    self.assertPropertiesEqual(properties, request)
Example #4
0
  def testViewInvite(self):
    self.data.createProfile()
    invitation = self.createInvitation()
    url = '/gsoc/invitation/%s/%s' % (self.gsoc.key().name(), invitation.key().id())
    response = self.client.get(url)
    self.assertGSoCTemplatesUsed(response)
    self.assertTemplateUsed(response, 'v2/soc/request/base.html')

    postdata = {'action': 'Reject'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invitation = Request.all().get()
    self.assertEqual('rejected', invitation.status)

    # test that you can change after the fact
    postdata = {'action': 'Accept'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
Example #5
0
    def testRequestMentor(self):
        # test GET
        self.data.createProfile()
        url = '/gsoc/request/' + self.org.key().name()
        response = self.client.get(url)
        self.assertRequestTemplatesUsed(response)

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

        request = Request.all().get()
        self.assertPropertiesEqual(properties, request)
Example #6
0
  def testViewInvite(self):
    self.data.createProfile()
    invitation = self.createInvitation()
    url = '/gsoc/invitation/%s/%s' % (self.gsoc.key().name(), invitation.key().id())
    response = self.get(url)
    self.assertGSoCTemplatesUsed(response)
    self.assertTemplateUsed(response, 'v2/soc/request/base.html')

    postdata = {'action': 'Reject'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invitation = Request.all().get()
    self.assertEqual('rejected', invitation.status)

    # test that you can change after the fact
    postdata = {'action': 'Accept'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)

    profile = db.get(self.data.profile.key())
    self.assertEqual(1, profile.mentor_for.count(self.org.key()))
    self.assertTrue(profile.is_mentor)
    self.assertFalse(profile.is_student)
    self.assertFalse(profile.is_org_admin)
    self.assertFalse(profile.org_admin_for)

    # test admin invite
    invitation.status = 'pending'
    invitation.role = 'org_admin'
    invitation.put()

    response = self.post(url, postdata)
    self.assertResponseRedirect(response)

    profile = db.get(self.data.profile.key())
    self.assertEqual(1, profile.mentor_for.count(self.org.key()))
    self.assertEqual(1, profile.org_admin_for.count(self.org.key()))
    self.assertFalse(profile.is_student)
    self.assertTrue(profile.is_mentor)
    self.assertTrue(profile.is_org_admin)
Example #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',
        # TODO(SRabbelier): add this as soon as we make User Request's parent
        # 'parent': other_user,
    }
    response, properties = self.modelPost(url, Request, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

    invitation = Request.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, Request, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

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

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

    other_data.notificationSettings(invite_handled=True)

    postdata = {'action': 'Withdraw'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invite = Request.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 = Request.all().get()
    self.assertEqual('pending', invite.status)
    self.assertEmailSent(to=other_data.profile.email, n=3)