def test_get_host(self): target1 = URI.address("db1.pilosa.com") target2 = URI.address("db2.pilosa.com") c = Cluster() c.add_host(URI.address("db1.pilosa.com")) c.add_host(URI.address("db2.pilosa.com")) addr = c.get_host() self.assertEquals(target1, addr) addr = c.get_host() self.assertEquals(target1, addr) c.get_host() c.remove_host(URI.address("db1.pilosa.com")) addr = c.get_host() self.assertEquals(target2, addr)
def test_add_remove_host(self): target = [(URI.address("http://localhost:3000"), True)] c = Cluster() c.add_host(URI.address("http://localhost:3000")) # add the same host, the list of hosts should be the same c.add_host(URI.address("http://localhost:3000")) self.assertEquals(target, c.hosts) target = [(URI.address("http://localhost:3000"), True), (URI(), True)] c.add_host(URI()) self.assertEquals(target, c.hosts) target = [(URI.address("http://localhost:3000"), False), (URI(), True)] c.remove_host(URI.address("http://localhost:3000")) self.assertEquals(target, c.hosts)