Beispiel #1
0
def serve_request(path, user=None):
    """Given an URL path, return response.
    """
    request = StubRequest(path)
    request.website = test_website
    if user is not None:
        user = User.from_id(user)
        # Note that Cookie needs a bytestring.
        request.headers.cookie[str('session')] = user.session_token
    response = test_website.handle_safely(request)
    return response
Beispiel #2
0
    def perform_request(self, request, user):
        request.website = test_website
        if user is not None:
            user = User.from_username(user)
            # Note that Cookie needs a bytestring.
            request.headers.cookie[str('session')] = user.session_token

        response = test_website.handle_safely(request)
        if response.headers.cookie:
            self.cookies.update(response.headers.cookie)
        return response
Beispiel #3
0
    def perform_request(self, request, user):
        request.website = test_website
        if user is not None:
            user = User.from_id(user)
            # Note that Cookie needs a bytestring.
            request.headers.cookie[str('session')] = user.session_token

        response = test_website.handle_safely(request)
        if response.headers.cookie:
            self.cookies.update(response.headers.cookie)
        return response
def serve_request(path, user=None):
    """Given an URL path, return response.
    """
    request = StubRequest(path)
    request.website = test_website
    if user is not None:
        user = User.from_id(user)
        # Note that Cookie needs a bytestring.
        request.headers.cookie[str('session')] = user.session_token
    response = test_website.handle_safely(request)
    return response
 def opt_in(self, desired_participant_id):
     """Given a desired participant_id, return a User object.
     """
     self.set_is_locked(False)
     user = User.from_id(self.participant_id)  # give them a session
     if not self.is_claimed:
         user.set_as_claimed()
         try:
             user.change_id(desired_participant_id)
             user.id = self.participant_id = desired_participant_id
         except user.ProblemChangingId:
             pass
     return user
Beispiel #6
0
 def opt_in(self, desired_participant_id):
     """Given a desired participant_id, return a User object.
     """
     self.set_is_locked(False)
     user = User.from_id(self.participant_id)  # give them a session
     if not self.is_claimed:
         user.set_as_claimed()
         try:
             user.change_id(desired_participant_id)
             user.id = self.participant_id = desired_participant_id
         except user.ProblemChangingId:
             pass
     return user
Beispiel #7
0
 def opt_in(self, desired_username):
     """Given a desired username, return a User object.
     """
     self.set_is_locked(False)
     user = User.from_username(self.participant)  # give them a session
     assert not user.ANON, self.participant  # sanity check
     if self.is_claimed:
         newly_claimed = False
     else:
         newly_claimed = True
         user.set_as_claimed()
         try:
             user.change_username(desired_username)
             user.username = self.username = desired_username
         except user.ProblemChangingUsername:
             pass
     return user, newly_claimed
Beispiel #8
0
 def opt_in(self, desired_username):
     """Given a desired username, return a User object.
     """
     self.set_is_locked(False)
     user = User.from_username(self.participant)  # give them a session
     assert not user.ANON, self.participant  # sanity check
     if self.is_claimed:
         newly_claimed = False
     else:
         newly_claimed = True
         user.set_as_claimed()
         try:
             user.change_username(desired_username)
             user.username = self.username = desired_username
         except user.ProblemChangingUsername:
             pass
     return user, newly_claimed