コード例 #1
0
ファイル: tracer.py プロジェクト: petrhosek/storm
 def test_success_finishes_action(self):
     tracer = TimelineTracer(self.factory)
     action = timeline.Timeline().start('foo', 'bar')
     tracer.threadinfo.action = action
     tracer.connection_raw_execute_success(
         'conn', 'cursor', 'statement', 'params')
     self.assertNotEqual(None, action.duration)
コード例 #2
0
 def test_success_finishes_action(self):
     tracer = TimelineTracer(self.factory)
     action = timeline.Timeline().start('foo', 'bar')
     tracer.threadinfo.action = action
     tracer.connection_raw_execute_success('conn', 'cursor', 'statement',
                                           'params')
     self.assertNotEqual(None, action.duration)
コード例 #3
0
ファイル: tracer.py プロジェクト: petrhosek/storm
    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)
コード例 #4
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)
コード例 #5
0
ファイル: tracer.py プロジェクト: petrhosek/storm
 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)
コード例 #6
0
ファイル: tracer.py プロジェクト: petrhosek/storm
 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)
コード例 #7
0
ファイル: tracer.py プロジェクト: petrhosek/storm
 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)
コード例 #8
0
ファイル: tracer.py プロジェクト: petrhosek/storm
 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))
コード例 #9
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)
コード例 #10
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)
コード例 #11
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)
コード例 #12
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)
コード例 #13
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))
コード例 #14
0
 def test_separate_tracers_own_state(self):
     """Check that multiple TimelineTracer's could be used at once."""
     tracer1 = TimelineTracer(self.factory)
     tracer2 = TimelineTracer(self.factory)
     tracer1.threadinfo.action = 'foo'
     self.assertEqual(None, getattr(tracer2.threadinfo, 'action', None))
コード例 #15
0
ファイル: tracer.py プロジェクト: DamnWidget/mamba-storm
 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)