Files
deb-python-cassandra-driver/cqlengine/tests/connections/test_connection_pool.py
Kai Lautaportti 2951ba35de Use CL.ONE explicitly when interacting with the system keyspace
The system keyspace uses  "LocalStrategy" for replication so it needs to
be accessed with CL.ONE. If the default consistency level is set to
something else all management commands which rely on introspecting the
system keyspace will fail.
2013-12-10 10:36:11 +02:00

23 lines
675 B
Python

from unittest import TestCase
from cql import OperationalError
from mock import MagicMock, patch, Mock
from cqlengine import ONE
from cqlengine.connection import ConnectionPool, Host
class OperationalErrorLoggingTest(TestCase):
def test_logging(self):
p = ConnectionPool([Host('127.0.0.1', '9160')])
class MockConnection(object):
host = 'localhost'
port = 6379
def cursor(self):
raise OperationalError('test')
with patch.object(p, 'get', return_value=MockConnection()):
with self.assertRaises(OperationalError):
p.execute("select * from system.peers", {}, ONE)