PYTHON-103, PYTHON-415, Adding tests for host resolution, and duplication
This commit is contained in:
@@ -41,6 +41,38 @@ def setup_module():
|
|||||||
|
|
||||||
class ClusterTests(unittest.TestCase):
|
class ClusterTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_host_resolution(self):
|
||||||
|
"""
|
||||||
|
Test to insure A records are resolved appropriately.
|
||||||
|
|
||||||
|
@since 3.3
|
||||||
|
@jira_ticket PYTHON-415
|
||||||
|
@expected_result hostname will be transformed into IP
|
||||||
|
|
||||||
|
@test_category connection
|
||||||
|
"""
|
||||||
|
cluster = Cluster(contact_points=["localhost"], protocol_version=PROTOCOL_VERSION, connect_timeout=1)
|
||||||
|
self.assertTrue('127.0.0.1' in cluster.contact_points_resolved)
|
||||||
|
|
||||||
|
def test_host_duplication(self):
|
||||||
|
"""
|
||||||
|
Ensure that duplicate hosts in the contact points are surfaced in the cluster metadata
|
||||||
|
|
||||||
|
@since 3.3
|
||||||
|
@jira_ticket PYTHON-103
|
||||||
|
@expected_result duplicate hosts aren't surfaced in cluster.metadata
|
||||||
|
|
||||||
|
@test_category connection
|
||||||
|
"""
|
||||||
|
cluster = Cluster(contact_points=["localhost", "127.0.0.1", "localhost", "localhost", "localhost"], protocol_version=PROTOCOL_VERSION, connect_timeout=1)
|
||||||
|
cluster.connect()
|
||||||
|
self.assertEqual(len(cluster.metadata.all_hosts()), 3)
|
||||||
|
cluster.shutdown()
|
||||||
|
cluster = Cluster(contact_points=["127.0.0.1", "localhost"], protocol_version=PROTOCOL_VERSION, connect_timeout=1)
|
||||||
|
cluster.connect()
|
||||||
|
self.assertEqual(len(cluster.metadata.all_hosts()), 3)
|
||||||
|
cluster.shutdown()
|
||||||
|
|
||||||
def test_raise_error_on_control_connection_timeout(self):
|
def test_raise_error_on_control_connection_timeout(self):
|
||||||
"""
|
"""
|
||||||
Test for initial control connection timeout
|
Test for initial control connection timeout
|
||||||
|
|||||||
@@ -20,10 +20,19 @@ except ImportError:
|
|||||||
from mock import patch, Mock
|
from mock import patch, Mock
|
||||||
|
|
||||||
from cassandra import ConsistencyLevel
|
from cassandra import ConsistencyLevel
|
||||||
from cassandra.cluster import _Scheduler, Session
|
from cassandra.cluster import _Scheduler, Session, Cluster
|
||||||
from cassandra.query import SimpleStatement
|
from cassandra.query import SimpleStatement
|
||||||
|
|
||||||
|
|
||||||
|
class ContactListTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_invalid_types(self, *args):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
Cluster(contact_points=[None], protocol_version=4, connect_timeout=1)
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
Cluster(contact_points="not a sequence", protocol_version=4, connect_timeout=1)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerTest(unittest.TestCase):
|
class SchedulerTest(unittest.TestCase):
|
||||||
# TODO: this suite could be expanded; for now just adding a test covering a ticket
|
# TODO: this suite could be expanded; for now just adding a test covering a ticket
|
||||||
|
|
||||||
@@ -35,9 +44,6 @@ class SchedulerTest(unittest.TestCase):
|
|||||||
|
|
||||||
PYTHON-473
|
PYTHON-473
|
||||||
"""
|
"""
|
||||||
sched = _Scheduler(None)
|
|
||||||
sched.schedule(0, lambda: None)
|
|
||||||
sched.schedule(0, lambda: None) # pre-473: "TypeError: unorderable types: function() < function()"t
|
|
||||||
|
|
||||||
|
|
||||||
class SessionTest(unittest.TestCase):
|
class SessionTest(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user