Ejemplo n.º 1
0
 def test_multiple_nested_children_permitted(self):
     # nesting is not reset by each action that is added.
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     child = timeline.start("SQL Callback", "SELECT...")
     child.finish()
     child = timeline.start("SQL Callback", "SELECT...")
Ejemplo n.º 2
0
 def test_start_after_finish_works(self):
     timeline = Timeline()
     action = timeline.start("Sending mail", "Noone")
     action.finish()
     action = timeline.start("Sending mail", "Noone")
     action.finish()
     self.assertEqual(2, len(timeline.actions))
Ejemplo n.º 3
0
 def test_nested_start_is_not_transitive(self):
     # nesting is explicit at each level - not inherited.
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     child = timeline.start("SQL Callback", "SELECT...")
     self.assertRaises(OverlappingActionError, timeline.start,
         "Sending mail", "Noone")
Ejemplo n.º 4
0
 def test_multiple_starts_after_nested_group_prevented(self):
     # nesting stops being permitted when the nesting action is finished.
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     action.finish()
     child = timeline.start("SQL Callback", "SELECT...")
     self.assertRaises(OverlappingActionError, timeline.start,
         "Sending mail", "Noone")
Ejemplo n.º 5
0
 def test_nested_actions_recorded_as_two_zero_length_actions(self):
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     child = timeline.start("SQL Callback", "SELECT...")
     child.finish()
     action.finish()
     self.assertEqual(3, len(timeline.actions))
     self.assertEqual(datetime.timedelta(), timeline.actions[0].duration)
     self.assertEqual(datetime.timedelta(), timeline.actions[2].duration)
Ejemplo n.º 6
0
 def test_session_queries_filtered(self):
     """Test that session queries are filtered."""
     utility = ErrorReportingUtility()
     utility._oops_config.publisher = None
     timeline = Timeline()
     timeline.start("SQL-session", "SELECT 'gone'").finish()
     try:
         raise ArbitraryException('foo')
     except ArbitraryException:
         info = sys.exc_info()
         oops = utility._oops_config.create(
             dict(exc_info=info, timeline=timeline))
     self.assertEqual("SELECT '%s'", oops['timeline'][0][3])
Ejemplo n.º 7
0
 def test_session_queries_filtered(self):
     """Test that session queries are filtered."""
     utility = ErrorReportingUtility()
     del utility._oops_config.publishers[:]
     timeline = Timeline()
     timeline.start("SQL-session", "SELECT 'gone'").finish()
     try:
         raise ArbitraryException('foo')
     except ArbitraryException:
         info = sys.exc_info()
         oops = utility._oops_config.create(
                 dict(exc_info=info, timeline=timeline))
     self.assertEqual("SELECT '%s'", oops['timeline'][0][3])
Ejemplo n.º 8
0
 def test_start_with_unfinished_action_fails(self):
     # A design constraint of timeline says that overlapping actions are not
     # permitted. See the Timeline docstrings.
     timeline = Timeline()
     action = timeline.start("Sending mail", "Noone")
     self.assertRaises(OverlappingActionError, timeline.start,
         "Sending mail", "Noone")
Ejemplo n.º 9
0
 def test_start_sets_backtrace_by_default(self):
     timeline = Timeline()
     action = timeline.start("Sending mail", "Noone")
     self.assertNotEqual(None, action.backtrace)
     self.assertIsInstance(action.backtrace, str)
     self.assertThat(action.backtrace,
         EndsWith('    action = timeline.start("Sending mail", "Noone")\n'))
Ejemplo n.º 10
0
 def test_start_returns_action(self):
     timeline = Timeline()
     action = timeline.start("Sending mail", "Noone")
     self.assertIsInstance(action, TimedAction)
     self.assertEqual("Sending mail", action.category)
     self.assertEqual("Noone", action.detail)
     self.assertEqual(None, action.duration)
     self.assertEqual(timeline, action.timeline)
Ejemplo n.º 11
0
 def test_nested_category_labels(self):
     # To identify start/stop pairs '-start' and '-stop' are put onto the
     # category of nested actions:
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     action.finish()
     self.assertEqual('Calling openid-start', timeline.actions[0].category)
     self.assertEqual('Calling openid-stop', timeline.actions[1].category)
Ejemplo n.º 12
0
 def test_finishing_nested_within_nested_leaves_outer_nested_nesting(self):
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     middle = timeline.start("Calling otherlibrary", "", allow_nested=True)
     middle.finish()
     child = timeline.start("SQL Callback", "SELECT...")
Ejemplo n.º 13
0
 def test_nesting_within_nesting_permitted(self):
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     middle = timeline.start("Calling otherlibrary", "", allow_nested=True)
     child = timeline.start("SQL Callback", "SELECT...")
Ejemplo n.º 14
0
 def test_nested_start_permitted(self):
     # When explicitly requested a nested start can be done
     timeline = Timeline()
     action = timeline.start("Calling openid", "hostname", allow_nested=True)
     child = timeline.start("SQL Callback", "SELECT...")
Ejemplo n.º 15
0
 def test_backtraces_can_be_disabled(self):
     # Passing format_stack=None to Timeline prevents backtrace gathering.
     timeline = Timeline(format_stack=None)
     action = timeline.start("Sending mail", "Noone")
     self.assertEqual(None, action.backtrace)