MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / MockMetadata

Class MockMetadata

tests/unit/test_control_connection.py:33–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33class MockMetadata(object):
34
35 def __init__(self):
36 self.hosts = {
37 DefaultEndPoint("192.168.1.0"): Host(DefaultEndPoint("192.168.1.0"), SimpleConvictionPolicy),
38 DefaultEndPoint("192.168.1.1"): Host(DefaultEndPoint("192.168.1.1"), SimpleConvictionPolicy),
39 DefaultEndPoint("192.168.1.2"): Host(DefaultEndPoint("192.168.1.2"), SimpleConvictionPolicy)
40 }
41 for host in self.hosts.values():
42 host.set_up()
43 host.release_version = "3.11"
44
45 self.cluster_name = None
46 self.partitioner = None
47 self.token_map = {}
48
49 def get_host(self, endpoint_or_address, port=None):
50 if not isinstance(endpoint_or_address, EndPoint):
51 for host in self.hosts.values():
52 if (host.address == endpoint_or_address and
53 (port is None or host.broadcast_rpc_port is None or host.broadcast_rpc_port == port)):
54 return host
55 else:
56 return self.hosts.get(endpoint_or_address)
57
58 def all_hosts(self):
59 return self.hosts.values()
60
61 def rebuild_token_map(self, partitioner, token_map):
62 self.partitioner = partitioner
63 self.token_map = token_map
64
65
66class MockCluster(object):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by 1

__init__Method · 0.68