def test_join_pool(self): req = join_pool_request('127.0.1.1:8080', '127.0.1.1:8081') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [ {"index": 0, "state": "pooling", "address": "127.0.1.1:8081"}, {"index": 1, "state": "pooling", "address": "127.0.1.1:8080"} ] ) req = get_pool_request('127.0.0.1:8081') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [ {"index": 0, "state": "pooling", "address": "127.0.1.1:8081"}, {"index": 1, "state": "pooling", "address": "127.0.1.1:8080"} ] ) req = get_pool_request('127.0.0.1:8080') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [ {"index": 0, "state": "pooling", "address": "127.0.1.1:8081"}, {"index": 1, "state": "pooling", "address": "127.0.1.1:8080"} ] ) req = join_pool_request('127.0.1.1:8082', '127.0.1.1:8081') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [ {"index": 0, "state": "pooling", "address": "127.0.1.1:8081"}, {"index": 1, "state": "pooling", "address": "127.0.1.1:8080"}, {"index": 2, "state": "pooling", "address": "127.0.1.1:8082"} ] ) req = get_pool_request('127.0.0.1:8081') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [ {"index": 0, "state": "pooling", "address": "127.0.1.1:8081"}, {"index": 1, "state": "pooling", "address": "127.0.1.1:8080"}, {"index": 2, "state": "pooling", "address": "127.0.1.1:8082"} ] )
def test_get_pool(self): req = get_pool_request('127.0.0.1:8080') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [{"index": 0, "state": "alone", "address": "127.0.1.1:8080"}] ) req = get_pool_request('127.0.0.1:8081') data = urllib2.urlopen(req) self.assertEqual( cjson.decode(data.read()), [{"index": 0, "state": "alone", "address": "127.0.1.1:8081"}] )