def test_multiple_calls(self): # Asking to record the OOPS twice just returns the same ID. request = get_current_browser_request() request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True maybe_record_user_requested_oops() orig_oops_id = request.oopsid maybe_record_user_requested_oops() self.assertEqual(orig_oops_id, request.oopsid)
def test_existing_oops_stops_user_requested(self): # If there is already an existing oops id in the request, then the # user requested oops is ignored. request = get_current_browser_request() request.oopsid = "EXISTING" request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True maybe_record_user_requested_oops() self.assertEqual("EXISTING", request.oopsid)
def test_existing_oops_stops_user_requested(self): # If there is already an existing oops id in the request, then the # user requested oops is ignored. request = get_current_browser_request() request.oopsid = "EXISTING" request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True maybe_record_user_requested_oops() self.assertEqual("EXISTING", request.oopsid)
def test_multiple_calls(self): # Asking to record the OOPS twice just returns the same ID. request = get_current_browser_request() request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True maybe_record_user_requested_oops() orig_oops_id = request.oopsid maybe_record_user_requested_oops() self.assertEqual(orig_oops_id, request.oopsid)
def test_annotation_key(self): # The request for an oops is stored in the request annotations. # If a user request oops is recorded, the oops id is stored in # the request. request = get_current_browser_request() request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True self.assertIs(None, request.oopsid) maybe_record_user_requested_oops() self.assertIsNot(None, request.oopsid)
def test_annotation_key(self): # The request for an oops is stored in the request annotations. # If a user request oops is recorded, the oops id is stored in # the request. request = get_current_browser_request() request.annotations[LAZR_OOPS_USER_REQUESTED_KEY] = True self.assertIs(None, request.oopsid) maybe_record_user_requested_oops() self.assertIsNot(None, request.oopsid)
def summarize_requests(): """Produce human-readable summary of requests issued so far.""" secs = get_request_duration() request = get_current_browser_request() timeline = get_request_timeline(request) from lp.services.webapp.errorlog import (maybe_record_user_requested_oops) maybe_record_user_requested_oops() if request.oopsid is None: oops_str = "" else: oops_str = " %s" % request.oopsid log = "%s queries/external actions issued in %.2f seconds%s" % (len( timeline.actions), secs, oops_str) return log
def summarize_requests(): """Produce human-readable summary of requests issued so far.""" secs = get_request_duration() request = get_current_browser_request() timeline = get_request_timeline(request) from lp.services.webapp.errorlog import ( maybe_record_user_requested_oops) maybe_record_user_requested_oops() if request.oopsid is None: oops_str = "" else: oops_str = " %s" % request.oopsid log = "%s queries/external actions issued in %.2f seconds%s" % ( len(timeline.actions), secs, oops_str) return log
def test_none_requested(self): # If an oops was not requested, then maybe_record_user_requested_oops # does not record an oops. request = get_current_browser_request() maybe_record_user_requested_oops() self.assertIs(None, request.oopsid)
def test_none_requested(self): # If an oops was not requested, then maybe_record_user_requested_oops # does not record an oops. request = get_current_browser_request() maybe_record_user_requested_oops() self.assertIs(None, request.oopsid)