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)
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.')
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)
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)
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)