def test_update_slot(self): clustermap = ClusterMap(self.seeds) clustermap._update_slot(0, ['127.0.0.1', 7000], [['127.0.0.1', 7003]]) self.assertEqual( clustermap._map[0], {'master': '127.0.0.1_7000', 'slave': '127.0.0.1_7003'} )
def test_update_slot(self): clustermap = ClusterMap(self.seeds) clustermap._update_slot(0, ['127.0.0.1', 7000], [['127.0.0.1', 7003]]) self.assertEqual(clustermap._map[0], { 'master': '127.0.0.1_7000', 'slave': '127.0.0.1_7003' })
def test_update(self): clustermap = ClusterMap(self.seeds) update = Mock() id = clustermap.id clustermap._update_slot = update clustermap._fetch_map = Mock() clustermap._fetch_map.return_value = self.minimap id_new = clustermap.update(clustermap.id) clustermap._update_slot.assert_has_calls([ call(0, [u'127.0.0.1', 7000], [[u'127.0.0.1', 7003]]), call(1, [u'127.0.0.1', 7000], [[u'127.0.0.1', 7003]]), call(2, [u'127.0.0.1', 7000], [[u'127.0.0.1', 7003]]), call(3, [u'127.0.0.1', 7001], [[u'127.0.0.1', 7004]]), call(4, [u'127.0.0.1', 7002], [[u'127.0.0.1', 7005]]), call(5, [u'127.0.0.1', 7002], [[u'127.0.0.1', 7005]]) ]) self.assertNotEqual(clustermap.id, id) self.assertEqual(clustermap.id, id_new)
def test_update(self): clustermap = ClusterMap(self.seeds) update = Mock() id = clustermap.id clustermap._update_slot = update clustermap._fetch_map = Mock() clustermap._fetch_map.return_value = self.minimap id_new = clustermap.update(clustermap.id) clustermap._update_slot.assert_has_calls( [ call(0, ['127.0.0.1', 7000], [['127.0.0.1', 7003]]), call(1, ['127.0.0.1', 7000], [['127.0.0.1', 7003]]), call(2, ['127.0.0.1', 7000], [['127.0.0.1', 7003]]), call(3, ['127.0.0.1', 7001], [['127.0.0.1', 7004]]), call(4, ['127.0.0.1', 7002], [['127.0.0.1', 7005]]), call(5, ['127.0.0.1', 7002], [['127.0.0.1', 7005]]) ] ) self.assertNotEqual(clustermap.id, id) self.assertEqual(clustermap.id, id_new)