Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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))
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
 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))
Beispiel #12
0
 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)