示例#1
0
 def test_unicode(self):
     client = clblob.client.Client(self.config)
     info = client.put(u'☮', u'peace!')
     self.assertEquals(u'00101_☮', info['name'])
     self.assertEquals('peace!', client.get(info['name']).read())
     self.assertEquals(info, client.get(info['name'], 'info'))
     client.delete(info['name'])
     self.assertRaises(clblob.RequestError, client.put, '1', u'☮')
示例#2
0
 def test_unicode(self):
     client = clblob.client.Client(self.config)
     info = client.put(u"☮", u"peace!")
     self.assertEquals(u"00101_☮", info["name"])
     self.assertEquals("peace!", client.get(info["name"]).read())
     self.assertEquals(info, client.get(info["name"], "info"))
     client.delete(info["name"])
     self.assertRaises(clblob.RequestError, client.put, "1", u"☮")
示例#3
0
 def test_unicode(self):
     client = clblob.client.Client(self.config)
     info = client.put(u'☮', u'peace!')
     self.assertEquals(u'00101_☮', info['name'])
     self.assertEquals('peace!', client.get(info['name']).read())
     self.assertEquals(info, client.get(info['name'], 'info'))
     client.delete(info['name'])
     self.assertRaises(clblob.RequestError, client.put, '1', u'☮')
 def test_save_blob(self):
     processor = climage.processor.Processor(self.config, open(IMAGE))
     images = processor.process()
     self.assertTrue("blob_info_name" in processor.info)
     self.assertTrue("blob_names" in processor.info)
     client = clblob.client.Client(self.config)
     info = processor.info.copy()
     info.pop("blob_info_name")
     info.pop("blob_names")
     self.assertEquals(info, json.loads(client.get(processor.info["blob_info_name"]).read()))
     for size in images:
         self.assertEquals(images[size], client.get(processor.info["blob_names"][size]).read())
示例#5
0
    def test_get(self):
        client = clblob.client.Client(self.config)
        data = str(range(100000))
        data_hash = hashlib.md5(data).hexdigest()  # pylint: disable=E1101
        info = client.put(NAME, data)

        time.sleep(0.2)
        data2 = client.get(ENCODED).read()
        self.assertEquals(data_hash, hashlib.md5(data2).hexdigest())  # pylint: disable=E1101

        self.assertEquals(info, client.get(ENCODED, 'info'))
        self.assertRaises(clblob.RequestError, client.get, ENCODED, 'bad')
        self.assertRaises(clblob.NotFound, client.get, '00102_test5')
        self.assertRaises(clblob.NotFound, client.get, '00102_test5', 'info')
示例#6
0
    def test_get(self):
        client = clblob.client.Client(self.config)
        data = str(range(100000))
        data_hash = hashlib.md5(data).hexdigest()  # pylint: disable=E1101
        info = client.put(NAME, data)

        time.sleep(0.2)
        data2 = client.get(ENCODED).read()
        self.assertEquals(data_hash, hashlib.md5(data2).hexdigest())  # pylint: disable=E1101

        self.assertEquals(info, client.get(ENCODED, "info"))
        self.assertRaises(clblob.RequestError, client.get, ENCODED, "bad")
        self.assertRaises(clblob.NotFound, client.get, "00102_test5")
        self.assertRaises(clblob.NotFound, client.get, "00102_test5", "info")
 def test_save_blob(self):
     processor = climage.processor.Processor(self.config, open(IMAGE))
     images = processor.process()
     self.assertTrue('blob_info_name' in processor.info)
     self.assertTrue('blob_names' in processor.info)
     client = clblob.client.Client(self.config)
     info = processor.info.copy()
     info.pop('blob_info_name')
     info.pop('blob_names')
     self.assertEquals(
         info,
         json.loads(client.get(processor.info['blob_info_name']).read()))
     for size in images:
         self.assertEquals(
             images[size],
             client.get(processor.info['blob_names'][size]).read())
示例#8
0
 def test_buffer(self):
     replicas = ["000", "010"]
     others = [server for server in self.servers if server not in replicas]
     for server in others:
         self.servers[server].stop()
     client = clblob.client.Client(self.config)
     names = []
     for count in xrange(20):
         names.append(client.put(str(count), str(count))["name"])
     time.sleep(0.2)
     for server in replicas:
         self.servers[server].stop()
     for server in others:
         self.servers[server].start()
     for name in names:
         self.assertRaises(clblob.RequestError, client.get, name)
     for server in replicas:
         self.servers[server].start()
     for _count in xrange(3):
         for server in replicas:
             client.buffer(server)
         time.sleep(0.2)
     for server in replicas:
         self.servers[server].stop()
     for count, name in enumerate(names):
         self.assertEquals(str(count), client.get(name).read())
     for server in replicas:
         self.servers[server].start()
示例#9
0
 def test_buffer(self):
     replicas = ['000', '010']
     others = [server for server in self.servers if server not in replicas]
     for server in others:
         self.servers[server].stop()
     client = clblob.client.Client(self.config)
     names = []
     for count in xrange(20):
         names.append(client.put(str(count), str(count))['name'])
     time.sleep(0.2)
     for server in replicas:
         self.servers[server].stop()
     for server in others:
         self.servers[server].start()
     for name in names:
         self.assertRaises(clblob.RequestError, client.get, name)
     for server in replicas:
         self.servers[server].start()
     for _count in xrange(3):
         for server in replicas:
             client.buffer(server)
         time.sleep(0.2)
     for server in replicas:
         self.servers[server].stop()
     for count, name in enumerate(names):
         self.assertEquals(str(count), client.get(name).read())
     for server in replicas:
         self.servers[server].start()
示例#10
0
 def test_put_old(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, "test data")
     time.sleep(0.2)
     info2 = client.put(NAME, "old test data", modified=info["modified"] - 1)
     self.assertEquals(info["modified"], info2["modified"])
     time.sleep(0.2)
     self.assertEquals("test data", client.get(ENCODED).read())
示例#11
0
 def test_put_old(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, 'test data')
     time.sleep(0.2)
     info2 = client.put(NAME, 'old test data',
         modified=info['modified'] - 1)
     self.assertEquals(info['modified'], info2['modified'])
     time.sleep(0.2)
     self.assertEquals('test data', client.get(ENCODED).read())
示例#12
0
 def test_put_old(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, 'test data')
     time.sleep(0.2)
     info2 = client.put(NAME, 'old test data',
         modified=info['modified'] - 1)
     self.assertEquals(info['modified'], info2['modified'])
     time.sleep(0.2)
     self.assertEquals('test data', client.get(ENCODED).read())
示例#13
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     names = []
     for count in xrange(20):
         names.append(client.put(str(count), 'test')['name'])
     time.sleep(0.2)
     self.servers['010'].stop()
     shutil.rmtree(os.path.join('test_blob', '010'))
     os.makedirs(os.path.join('test_blob', '010'))
     self.servers['010'].start()
     client.sync('010')
     time.sleep(0.2)
     self.servers['011'].stop()
     self.servers['012'].stop()
     for name in names:
         self.assertEquals('test', client.get(name).read())
     self.servers['011'].start()
     self.servers['012'].start()
示例#14
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     names = []
     for count in xrange(20):
         names.append(client.put(str(count), 'test')['name'])
     time.sleep(0.2)
     self.servers['010'].stop()
     shutil.rmtree(os.path.join('test_blob', '010'))
     os.makedirs(os.path.join('test_blob', '010'))
     self.servers['010'].start()
     client.sync('010')
     time.sleep(0.2)
     self.servers['011'].stop()
     self.servers['012'].stop()
     for name in names:
         self.assertEquals('test', client.get(name).read())
     self.servers['011'].start()
     self.servers['012'].start()
示例#15
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     names = []
     for count in xrange(20):
         names.append(client.put(str(count), "test")["name"])
     time.sleep(0.2)
     self.servers["010"].stop()
     shutil.rmtree(os.path.join("test_blob", "010"))
     os.makedirs(os.path.join("test_blob", "010"))
     self.servers["010"].start()
     client.sync("010")
     time.sleep(0.2)
     self.servers["011"].stop()
     self.servers["012"].stop()
     for name in names:
         self.assertEquals("test", client.get(name).read())
     self.servers["011"].start()
     self.servers["012"].start()
示例#16
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, 'test data')
     self.assertEquals(ENCODED, info['name'])
     time.sleep(0.5)
     self.assertEquals('test data', client.get(ENCODED).read())
示例#17
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, "test data")
     self.assertEquals(ENCODED, info["name"])
     time.sleep(0.5)
     self.assertEquals("test data", client.get(ENCODED).read())
示例#18
0
 def test_sync(self):
     client = clblob.client.Client(self.config)
     info = client.put(NAME, 'test data')
     self.assertEquals(ENCODED, info['name'])
     time.sleep(0.5)
     self.assertEquals('test data', client.get(ENCODED).read())