Ejemplo n.º 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"☮")
Ejemplo n.º 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'☮')
Ejemplo n.º 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'☮')
Ejemplo n.º 4
0
 def test_purge_worker(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, 'test data')
     time.sleep(0.2)
     for replica in REPLICAS:
         self.assertEquals(True, os.path.isfile(PATH % replica))
     client.delete(ENCODED, -200)
     time.sleep(2)
     for replica in REPLICAS:
         self.assertEquals(False, os.path.isfile(PATH % replica))
Ejemplo n.º 5
0
 def test_purge_worker(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, "test data")
     time.sleep(0.2)
     for replica in REPLICAS:
         self.assertEquals(True, os.path.isfile(PATH % replica))
     client.delete(ENCODED, -200)
     time.sleep(2)
     for replica in REPLICAS:
         self.assertEquals(False, os.path.isfile(PATH % replica))
Ejemplo n.º 6
0
 def test_undelete(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, 'undelete me')
     info = client.delete(ENCODED, 100)
     self.assertNotEquals(0, info['deleted'])
     info = client.delete(ENCODED, None)
     self.assertEquals(0, info['deleted'])
     info = client.delete(ENCODED, 100)
     self.assertNotEquals(0, info['deleted'])
     info = client.delete(ENCODED, deleted=0)
     self.assertEquals(0, info['deleted'])
Ejemplo n.º 7
0
 def test_undelete(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, "undelete me")
     info = client.delete(ENCODED, 100)
     self.assertNotEquals(0, info["deleted"])
     info = client.delete(ENCODED, None)
     self.assertEquals(0, info["deleted"])
     info = client.delete(ENCODED, 100)
     self.assertNotEquals(0, info["deleted"])
     info = client.delete(ENCODED, deleted=0)
     self.assertEquals(0, info["deleted"])
Ejemplo n.º 8
0
 def test_purge_bad_blob(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, 'test data')
     time.sleep(0.2)
     for replica in REPLICAS:
         self.assertEquals(True, os.path.isfile(PATH % replica))
     os.unlink(PATH % '010')
     os.mkdir(PATH % '010')
     client.delete(ENCODED, -200)
     time.sleep(0.2)
     client.purge('010')
     time.sleep(0.2)
     self.assertEquals(True, os.path.isdir(PATH % '010'))
     os.rmdir(PATH % '010')
     client.purge('010')
Ejemplo n.º 9
0
 def test_purge_bad_blob(self):
     client = clblob.client.Client(self.config)
     client.put(NAME, "test data")
     time.sleep(0.2)
     for replica in REPLICAS:
         self.assertEquals(True, os.path.isfile(PATH % replica))
     os.unlink(PATH % "010")
     os.mkdir(PATH % "010")
     client.delete(ENCODED, -200)
     time.sleep(0.2)
     client.purge("010")
     time.sleep(0.2)
     self.assertEquals(True, os.path.isdir(PATH % "010"))
     os.rmdir(PATH % "010")
     client.purge("010")
Ejemplo n.º 10
0
 def test_delete_before_old_put(self):
     client = clblob.client.Client(self.config)
     info = client.delete(ENCODED)
     time.sleep(0.2)
     info2 = client.put(NAME, "test data", modified=info["modified_deleted"] - 1)
     time.sleep(0.2)
     self.assertNotEquals(None, info2["modified"])
     self.assertNotEquals(0, info2["deleted"])
     self.assertEquals(info["modified_deleted"], info2["modified_deleted"])
Ejemplo n.º 11
0
 def test_delete_before_old_put(self):
     client = clblob.client.Client(self.config)
     info = client.delete(ENCODED)
     time.sleep(0.2)
     info2 = client.put(NAME, 'test data',
         modified=info['modified_deleted'] - 1)
     time.sleep(0.2)
     self.assertNotEquals(None, info2['modified'])
     self.assertNotEquals(0, info2['deleted'])
     self.assertEquals(info['modified_deleted'], info2['modified_deleted'])
Ejemplo n.º 12
0
 def test_delete_before_put(self):
     client = clblob.client.Client(self.config)
     info = client.delete(ENCODED)
     self.assertEquals(None, info["modified"])
     self.assertNotEquals(0, info["deleted"])
     time.sleep(0.2)
     self.assertRaises(clblob.NotFound, client.get, ENCODED)
     info2 = client.put(NAME, "test data")
     time.sleep(0.2)
     self.assertNotEquals(None, info2["modified"])
     self.assertEquals(0, info2["deleted"])
     self.assertNotEquals(info["modified_deleted"], info2["modified_deleted"])
Ejemplo n.º 13
0
 def test_delete_before_put(self):
     client = clblob.client.Client(self.config)
     info = client.delete(ENCODED)
     self.assertEquals(None, info['modified'])
     self.assertNotEquals(0, info['deleted'])
     time.sleep(0.2)
     self.assertRaises(clblob.NotFound, client.get, ENCODED)
     info2 = client.put(NAME, 'test data')
     time.sleep(0.2)
     self.assertNotEquals(None, info2['modified'])
     self.assertEquals(0, info2['deleted'])
     self.assertNotEquals(info['modified_deleted'],
         info2['modified_deleted'])
Ejemplo n.º 14
0
    def test_delete(self):
        client = clblob.client.Client(self.config)
        info = client.put(NAME, "delete me")
        self.assertEquals(0, info["deleted"])
        self.assertEquals(info["modified"], info["modified_deleted"])

        info2 = client.delete(ENCODED)
        self.assertNotEquals(0, info2["deleted"])
        self.assertTrue(info2["modified_deleted"] > info["modified_deleted"])

        info3 = client.delete(ENCODED, 100)
        self.assertNotEquals(0, info3["deleted"])
        self.assertTrue(info3["modified_deleted"] > info2["modified_deleted"])

        info4 = client.delete(ENCODED, deleted=info3["deleted"])
        self.assertEquals(info3["deleted"], info4["deleted"])
        self.assertTrue(info4["modified_deleted"] > info3["modified_deleted"])

        time.sleep(0.2)
        info5 = client.delete(ENCODED, modified_deleted=info4["modified_deleted"] - 1)
        self.assertEquals(info4["deleted"], info5["deleted"])
        self.assertEquals(info4["modified_deleted"], info5["modified_deleted"])
Ejemplo n.º 15
0
    def test_delete(self):
        client = clblob.client.Client(self.config)
        info = client.put(NAME, 'delete me')
        self.assertEquals(0, info['deleted'])
        self.assertEquals(info['modified'], info['modified_deleted'])

        info2 = client.delete(ENCODED)
        self.assertNotEquals(0, info2['deleted'])
        self.assertTrue(info2['modified_deleted'] > info['modified_deleted'])

        info3 = client.delete(ENCODED, 100)
        self.assertNotEquals(0, info3['deleted'])
        self.assertTrue(info3['modified_deleted'] > info2['modified_deleted'])

        info4 = client.delete(ENCODED, deleted=info3['deleted'])
        self.assertEquals(info3['deleted'], info4['deleted'])
        self.assertTrue(info4['modified_deleted'] > info3['modified_deleted'])

        time.sleep(0.2)
        info5 = client.delete(ENCODED,
            modified_deleted=info4['modified_deleted'] - 1)
        self.assertEquals(info4['deleted'], info5['deleted'])
        self.assertEquals(info4['modified_deleted'], info5['modified_deleted'])