Ejemplo n.º 1
0
 def testQueryInvalidToken(self):
     """Test that the function will fail to fetch any AnonymousConnections
 given a token that does not correspond to any objects.
 """
     connection = connection_logic.queryAnonymousConnectionForToken(
         'bad_token')
     self.assertIsNone(connection)
Ejemplo n.º 2
0
 def anonymousConnectionFromKwargs(self):
   """Set the anonymous_connection entity in the RequestData object.
   """
   token = self.data.kwargs['key']
   connection = connection_logic.queryAnonymousConnectionForToken(token)
   if connection:
     self.data.anonymous_connection = connection
   else:
     raise exception.Forbidden(
         message='Invalid key in url; unable to establish connection.')
Ejemplo n.º 3
0
 def anonymousConnectionFromKwargs(self):
     """Set the anonymous_connection entity in the RequestData object.
 """
     token = self.data.kwargs['key']
     connection = connection_logic.queryAnonymousConnectionForToken(token)
     if connection:
         self.data.anonymous_connection = connection
     else:
         raise exception.Forbidden(
             message='Invalid key in url; unable to establish connection.')
Ejemplo n.º 4
0
  def testQueryForAnonymousConnection(self):
    """Test that the function will correctly fetch AnonymousConnection objects
    given a valid token."""
    program = program_utils.seedProgram()
    org = org_utils.seedOrganization(program.key())

    connection_logic.createAnonymousConnection(org=org,
        org_role=connection_model.MENTOR_ROLE, email='*****@*****.**')
    token = connection_model.AnonymousConnection.all().get().token
    connection = connection_logic.queryAnonymousConnectionForToken(token)
    self.assertIsNotNone(connection)
Ejemplo n.º 5
0
    def testQueryForAnonymousConnection(self):
        """Test that the function will correctly fetch AnonymousConnection objects
    given a valid token."""
        program = program_utils.seedProgram()
        org = org_utils.seedOrganization(program.key())

        connection_logic.createAnonymousConnection(
            org=org,
            org_role=connection_model.MENTOR_ROLE,
            email='*****@*****.**')
        token = connection_model.AnonymousConnection.all().get().token
        connection = connection_logic.queryAnonymousConnectionForToken(token)
        self.assertIsNotNone(connection)
Ejemplo n.º 6
0
 def testQueryInvalidToken(self):
   """Test that the function will fail to fetch any AnonymousConnections
   given a token that does not correspond to any objects.
   """
   connection = connection_logic.queryAnonymousConnectionForToken('bad_token')
   self.assertIsNone(connection)