def test_category_from_prefix_and_connection_name(self): class StubConnection(Connection): def __init__(self): self._database = None self._event = None self._raw_connection = None self.name = 'Foo' tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute(StubConnection(), 'cursor', 'statement') self.assertEqual('bar-Foo', self.timeline.actions[-1].category)
def test_category_from_prefix_and_connection_name(self): class StubConnection(Connection): def __init__(self): self._database = None self._event = None self._raw_connection = None self.name = 'Foo' tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute(StubConnection(), 'cursor', 'statement') self.assertEqual('bar-Foo', self.timeline.actions[-1].category)
def test_default_prefix(self): """By default the prefix "SQL-" is added to the action's category.""" tracer = TimelineTracer(self.factory) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('SQL-<unknown>', self.timeline.actions[-1].category)
def test_unnamed_connection(self): """A connection with no name has <unknown> put in as a placeholder.""" tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('bar-<unknown>', self.timeline.actions[-1].category)
def test_action_details_are_statement(self): """The detail in the timeline action is the formatted SQL statement.""" tracer = TimelineTracer(self.factory) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('statement', self.timeline.actions[-1].detail)
def test_finds_timeline_from_factory(self): factory_result = timeline.Timeline() tracer = TimelineTracer(lambda: factory_result) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual(1, len(factory_result.actions))
def test_default_prefix(self): """By default the prefix "SQL-" is added to the action's category.""" tracer = TimelineTracer(self.factory) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('SQL-<unknown>', self.timeline.actions[-1].category)
def test_unnamed_connection(self): """A connection with no name has <unknown> put in as a placeholder.""" tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('bar-<unknown>', self.timeline.actions[-1].category)
def test_category_from_prefix_and_connection_name(self): tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute(StubConnection(), 'cursor', 'statement') self.assertEqual('bar-Foo', self.timeline.actions[-1].category)
def test_action_details_are_statement(self): """The detail in the timeline action is the formatted SQL statement.""" tracer = TimelineTracer(self.factory) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual('statement', self.timeline.actions[-1].detail)
def test_finds_timeline_from_factory(self): factory_result = timeline.Timeline() tracer = TimelineTracer(lambda: factory_result) tracer._expanded_raw_execute('conn', 'cursor', 'statement') self.assertEqual(1, len(factory_result.actions))
def test_category_from_prefix_and_connection_name(self): tracer = TimelineTracer(self.factory, prefix='bar-') tracer._expanded_raw_execute(StubConnection(), 'cursor', 'statement') self.assertEqual('bar-Foo', self.timeline.actions[-1].category)