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)
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
def test_replica(self): callback = mock.Mock() with DBRecorder('replica', callback): run_query('replica', 'SELECT 1') callback.assert_called_once_with(DBOp('replica', 'SELECT #'))
def test_secondary(self): callback = mock.Mock() with DBRecorder('second', callback): run_query('second', 'SELECT 1') callback.assert_called_once_with(DBOp('second', 'SELECT #'))
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
def test_replica(self): callback = mock.Mock() with DBRecorder("replica", callback): run_query("replica", "SELECT 1") callback.assert_called_once_with(DBOp("replica", "SELECT #"))
def test_secondary(self): callback = mock.Mock() with DBRecorder("second", callback): run_query("second", "SELECT 1") callback.assert_called_once_with(DBOp("second", "SELECT #"))
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))