示例#1
0
    def test_record_traceback(self):
        callback = mock.Mock()
        with DBRecorder("default", callback):
            run_query("default", "SELECT 1")

        assert len(callback.mock_calls) == 1
        assert "django_perf_rec/db.py" in str(
            callback.call_args_list[0][0][0].traceback)
示例#2
0
 def test_secondary_default_not_recorded(self):
     callback = mock.Mock()
     with DBRecorder('second', callback):
         run_query('default', 'SELECT 1')
     assert len(callback.mock_calls) == 0
示例#3
0
 def test_replica(self):
     callback = mock.Mock()
     with DBRecorder('replica', callback):
         run_query('replica', 'SELECT 1')
     callback.assert_called_once_with(DBOp('replica', 'SELECT #'))
示例#4
0
 def test_secondary(self):
     callback = mock.Mock()
     with DBRecorder('second', callback):
         run_query('second', 'SELECT 1')
     callback.assert_called_once_with(DBOp('second', 'SELECT #'))
示例#5
0
 def test_secondary_default_not_recorded(self):
     callback = mock.Mock()
     with DBRecorder("second", callback):
         run_query("default", "SELECT 1")
     assert len(callback.mock_calls) == 0
示例#6
0
 def test_replica(self):
     callback = mock.Mock()
     with DBRecorder("replica", callback):
         run_query("replica", "SELECT 1")
     callback.assert_called_once_with(DBOp("replica", "SELECT #"))
示例#7
0
 def test_secondary(self):
     callback = mock.Mock()
     with DBRecorder("second", callback):
         run_query("second", "SELECT 1")
     callback.assert_called_once_with(DBOp("second", "SELECT #"))
示例#8
0
 def test_default(self, extract_stack):
     callback = mock.Mock()
     with DBRecorder("default", callback):
         run_query("default", "SELECT 1")
     callback.assert_called_once_with(DBOp("default", "SELECT #", None))