def test_replication_strategy(self): """ Basic code coverage testing that ensures different ReplicationStrategies can be initiated using parameters correctly. """ rs = ReplicationStrategy() self.assertEqual(rs.create('OldNetworkTopologyStrategy', None), _UnknownStrategy('OldNetworkTopologyStrategy', None)) fake_options_map = {'options': 'map'} uks = rs.create('OldNetworkTopologyStrategy', fake_options_map) self.assertEqual(uks, _UnknownStrategy('OldNetworkTopologyStrategy', fake_options_map)) self.assertEqual(uks.make_token_replica_map({}, []), {}) fake_options_map = {'dc1': '3'} self.assertIsInstance(rs.create('NetworkTopologyStrategy', fake_options_map), NetworkTopologyStrategy) self.assertEqual(rs.create('NetworkTopologyStrategy', fake_options_map).dc_replication_factors, NetworkTopologyStrategy(fake_options_map).dc_replication_factors) fake_options_map = {'options': 'map'} self.assertIsNone(rs.create('SimpleStrategy', fake_options_map)) fake_options_map = {'options': 'map'} self.assertIsInstance(rs.create('LocalStrategy', fake_options_map), LocalStrategy) fake_options_map = {'options': 'map', 'replication_factor': 3} self.assertIsInstance(rs.create('SimpleStrategy', fake_options_map), SimpleStrategy) self.assertEqual(rs.create('SimpleStrategy', fake_options_map).replication_factor, SimpleStrategy(fake_options_map).replication_factor) self.assertEqual(rs.create('xxxxxxxx', fake_options_map), _UnknownStrategy('xxxxxxxx', fake_options_map)) self.assertRaises(NotImplementedError, rs.make_token_replica_map, None, None) self.assertRaises(NotImplementedError, rs.export_for_schema)
def test_replication_strategy(self): """ Basic code coverage testing that ensures different ReplicationStrategies can be initiated using parameters correctly. """ rs = ReplicationStrategy() self.assertEqual(rs.create('OldNetworkTopologyStrategy', None), _UnknownStrategy('OldNetworkTopologyStrategy', None)) fake_options_map = {'options': 'map'} uks = rs.create('OldNetworkTopologyStrategy', fake_options_map) self.assertEqual(uks, _UnknownStrategy('OldNetworkTopologyStrategy', fake_options_map)) self.assertEqual(uks.make_token_replica_map({}, []), {}) fake_options_map = {'dc1': '3'} self.assertIsInstance(rs.create('NetworkTopologyStrategy', fake_options_map), NetworkTopologyStrategy) self.assertEqual(rs.create('NetworkTopologyStrategy', fake_options_map).dc_replication_factors, NetworkTopologyStrategy(fake_options_map).dc_replication_factors) fake_options_map = {'options': 'map'} self.assertIsNone(rs.create('SimpleStrategy', fake_options_map)) fake_options_map = {'options': 'map'} self.assertIsInstance(rs.create('LocalStrategy', fake_options_map), LocalStrategy) fake_options_map = {'options': 'map', 'replication_factor': 3} self.assertIsInstance(rs.create('SimpleStrategy', fake_options_map), SimpleStrategy) self.assertEqual(rs.create('SimpleStrategy', fake_options_map).replication_factor, SimpleStrategy(fake_options_map).replication_factor) self.assertEqual(rs.create('xxxxxxxx', fake_options_map), _UnknownStrategy('xxxxxxxx', fake_options_map)) self.assertRaises(NotImplementedError, rs.make_token_replica_map, None, None) self.assertRaises(NotImplementedError, rs.export_for_schema)
def test_replication_strategy(self): """ Basic code coverage testing that ensures different ReplicationStrategies can be initiated using parameters correctly. """ rs = ReplicationStrategy() self.assertEqual( rs.create("OldNetworkTopologyStrategy", None), _UnknownStrategy("OldNetworkTopologyStrategy", None) ) fake_options_map = {"options": "map"} uks = rs.create("OldNetworkTopologyStrategy", fake_options_map) self.assertEqual(uks, _UnknownStrategy("OldNetworkTopologyStrategy", fake_options_map)) self.assertEqual(uks.make_token_replica_map({}, []), {}) fake_options_map = {"dc1": "3"} self.assertIsInstance(rs.create("NetworkTopologyStrategy", fake_options_map), NetworkTopologyStrategy) self.assertEqual( rs.create("NetworkTopologyStrategy", fake_options_map).dc_replication_factors, NetworkTopologyStrategy(fake_options_map).dc_replication_factors, ) fake_options_map = {"options": "map"} self.assertIsNone(rs.create("SimpleStrategy", fake_options_map)) fake_options_map = {"options": "map"} self.assertIsInstance(rs.create("LocalStrategy", fake_options_map), LocalStrategy) fake_options_map = {"options": "map", "replication_factor": 3} self.assertIsInstance(rs.create("SimpleStrategy", fake_options_map), SimpleStrategy) self.assertEqual( rs.create("SimpleStrategy", fake_options_map).replication_factor, SimpleStrategy(fake_options_map).replication_factor, ) self.assertEqual(rs.create("xxxxxxxx", fake_options_map), _UnknownStrategy("xxxxxxxx", fake_options_map)) self.assertRaises(NotImplementedError, rs.make_token_replica_map, None, None) self.assertRaises(NotImplementedError, rs.export_for_schema)