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_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_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))
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))
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'])
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"])
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')
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")
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"])
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'])
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"])
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'])
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"])
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'])