本文整理汇总了Python中pymogile.Client.store_content方法的典型用法代码示例。如果您正苦于以下问题:Python Client.store_content方法的具体用法?Python Client.store_content怎么用?Python Client.store_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymogile.Client
的用法示例。
在下文中一共展示了Client.store_content方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_read_file():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.store_content(key, key)
fp = client.read_file(key)
assert fp is not None
assert key == fp.read()
示例2: test_read_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_read_file(self):
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.store_content(key, key)
fp = client.read_file(key)
self.assertNotEqual(fp, None)
self.assertEqual(key, fp.read())
示例3: test_rename_dupliate_key
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_rename_dupliate_key(self):
client = Client(TEST_NS, HOSTS)
key1 = 'test_file_%s_%s' % (random.random(), time.time())
key2 = 'key2:' + key1
client.store_content(key1, key1)
client.store_content(key2, key2)
self.assertEqual(client.rename(key1, key2), False)
示例4: test_read_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_read_file():
cl = Client(TEST_NS, HOSTS)
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
cl.store_content(key, key)
with cl.read_file(key) as fp:
assert fp.read() == key
示例5: test_rename_dupliate_key
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_rename_dupliate_key():
client = Client(TEST_NS, HOSTS)
key1 = 'test_file_%s_%s' % (random.random(), time.time())
key2 = 'key2:' + key1
client.store_content(key1, key1)
client.store_content(key2, key2)
try:
client.rename(key1, key2)
except MogileFSError, e:
pass
示例6: test_readonly_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_readonly_file():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.store_content(key, "SPAM")
fp = client.read_file(key)
try:
fp.write("egg")
except:
pass
else:
assert False, "operation not permitted to read-only file"
示例7: test_seek_read
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_seek_read():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.store_content(key, "0123456789")
fp = client.read_file(key)
fp.seek(1)
assert fp.tell() == 1
content = fp.read(3)
assert content == "123"
assert fp.tell() == 4
示例8: test_seek_read
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_seek_read(self):
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.store_content(key, "0123456789")
fp = client.read_file(key)
fp.seek(1)
self.assertEqual(fp.tell(), 1)
content = fp.read(3)
assert content == "123"
self.assertEqual(fp.tell(), 4)
示例9: test_append_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_append_file(self):
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
cl.store_content(key, "SPAM")
self.assertTrue(cl.get_paths(key))
self.assertEqual("SPAM", cl.get_file_data(key))
fp = cl.edit_file(key)
self.assertTrue(fp)
fp.seek(4)
fp.write("HamEggs")
fp.close()
self.assertEqual("SPAMHamEggs", cl.get_file_data(key))
示例10: test_store_content
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_store_content():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
data = ''.join(random.choice("0123456789") for x in xrange(8192 * 2))
length = client.store_content(key, data)
assert length == len(data)
content = client.get_file_data(key)
assert content == data
示例11: test_store_content
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_store_content(self):
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
data = ''.join(random.choice("0123456789") for _ in xrange(8192 * 2))
length = client.store_content(key, data)
self.assertEqual(length, len(data))
content = client.get_file_data(key)
self.assertEqual(content, data)
示例12: test_edit_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_edit_file():
# TODO
# PASS
return
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
cl.store_content(key, "SPAM")
assert cl.get_paths(key)
assert cl.get_file_data(key) == "SPAM"
fp = cl.edit_file(key)
assert fp
fp.write("s")
fp.seek(2)
fp.write("a")
fp.close()
assert cl.get_file_data(key) == "sPaM"
示例13: test_list_keys
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import store_content [as 别名]
def test_list_keys():
keys = ["spam", "egg", "ham"]
domain = "test:list_keys:%s:%s:%s" % (random.random(), time.time(), TEST_NS)
moga.create_domain(domain)
mogc = Client(domain, HOSTS)
for k in keys:
mogc.store_content(k, k)
try:
files = mogc.list_keys()
assert len(files) == 3
files = mogc.list_keys(limit=1)
assert len(files) == 1
files = mogc.list_keys(prefix='sp')
assert len(files) == 1
finally:
for k in keys:
mogc.delete(k)
moga.delete_domain(domain)