当前位置: 首页>>代码示例>>Python>>正文


Python Client.store_content方法代码示例

本文整理汇总了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()
开发者ID:pombredanne,项目名称:pymogile,代码行数:10,代码来源:test_client.py

示例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())
开发者ID:cypreess,项目名称:pymogile,代码行数:10,代码来源:test_client.py

示例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)
开发者ID:cypreess,项目名称:pymogile,代码行数:11,代码来源:test_client.py

示例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
开发者ID:pombredanne,项目名称:pymogile,代码行数:11,代码来源:test_with_statement.py

示例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
开发者ID:pombredanne,项目名称:pymogile,代码行数:14,代码来源:test_client.py

示例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"
开发者ID:pombredanne,项目名称:pymogile,代码行数:14,代码来源:test_client.py

示例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
开发者ID:pombredanne,项目名称:pymogile,代码行数:15,代码来源:test_client.py

示例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)
开发者ID:cypreess,项目名称:pymogile,代码行数:15,代码来源:test_client.py

示例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))
开发者ID:cypreess,项目名称:pymogile,代码行数:17,代码来源:test_client.py

示例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
开发者ID:pombredanne,项目名称:pymogile,代码行数:12,代码来源:test_client.py

示例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)
开发者ID:cypreess,项目名称:pymogile,代码行数:12,代码来源:test_client.py

示例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"
开发者ID:pombredanne,项目名称:pymogile,代码行数:22,代码来源:test_client.py

示例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)
开发者ID:pombredanne,项目名称:pymogile,代码行数:24,代码来源:test_client.py


注:本文中的pymogile.Client.store_content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。