@patch('time.sleep', return_value=True)
def test_wait_for_db(self, ts):
    'Test waiting for db'
    with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
        gi.side_effect = (([OperationalError] * 5) + [True])
        call_command('wait_for_db')
        self.assertEqual(gi.call_count, 6)
Test waiting for db
@patch('time.sleep', return_value=True)
def test_wait_for_db(self, ts):
    
    with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
        gi.side_effect = (([OperationalError] * 5) + [True])
        call_command('wait_for_db')
        self.assertEqual(gi.call_count, 6)