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


Python Model.open方法代码示例

本文整理汇总了Python中binlog.model.Model.open方法的典型用法代码示例。如果您正苦于以下问题:Python Model.open方法的具体用法?Python Model.open怎么用?Python Model.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在binlog.model.Model的用法示例。


在下文中一共展示了Model.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_not_nested_inside_nested_connection

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_not_nested_inside_nested_connection(tmpdir):

    with Model.open(tmpdir) as conn1:

        with Model.open(tmpdir) as conn2_a:
            assert conn1 is conn2_a

        with Model.open(tmpdir) as conn2_b:
            assert conn1 is conn2_b
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_30_connection_with_manager.py

示例2: test_cant_remove_if_is_not_acked

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_cant_remove_if_is_not_acked(tmpdir):
    with Model.open(tmpdir) as db:
        e0 = db.create(test='data0')

        db.register_reader('reader1')

        assert db.remove(e0) is False
开发者ID:nilp0inter,项目名称:binlog,代码行数:9,代码来源:test_60_remove_entry.py

示例3: test_ack_on_anonymous_reader

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_ack_on_anonymous_reader(tmpdir):
    with Model.open(tmpdir) as db:
        entry = db.create(test='data')

        with db.reader() as reader:
            with pytest.raises(RuntimeError):
                reader.ack(reader[0])
开发者ID:nilp0inter,项目名称:binlog,代码行数:9,代码来源:test_50_ack.py

示例4: test_create_is_incremental

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_create_is_incremental(tmpdir):

    with Model.open(tmpdir) as db:
        entry0 = db.create()
        entry1 = db.create()

        assert entry0.pk == 0
        assert entry1.pk == 1
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_30_model_create.py

示例5: test_slice_step_cannot_be_zero

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_slice_step_cannot_be_zero(tmpdir):
    with Model.open(tmpdir) as db:
        entries = [Model(idx=i) for i in range(4)]
        db.bulk_create(entries)

        with db.reader() as reader:
            with pytest.raises(ValueError):
                reader[::0]
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_45_reader_slicing.py

示例6: test_reader_filter_exact

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_reader_filter_exact(tmpdir):
    with Model.open(tmpdir) as db:
        entries = [Model(idx=i, even=(i % 2 == 0)) for i in range(100)]
        db.bulk_create(entries)

        with db.reader() as r:
            for a, b in zip_longest(r.filter(even=True), range(0, 100, 2)):
                assert a.pk == b
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_40_reader.py

示例7: test_can_ack_with_pk

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_can_ack_with_pk(tmpdir):
    with Model.open(tmpdir) as db:
        entry = db.create(test='data')

        db.register_reader('myreader')
        with db.reader('myreader') as reader:
            reader.ack(0)
            assert 0 in reader.registry
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_50_ack.py

示例8: test_reader_unknown_negative_index

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_reader_unknown_negative_index(tmpdir):
    with Model.open(tmpdir) as db:
        db.create(test='test')

        db.register_reader('myreader')
        with db.reader('myreader') as reader:
            with pytest.raises(IndexError):
                reader[-2]
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_44_reader_get_index.py

示例9: test_cannot_use_same_connection_from_multiple_threads

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_cannot_use_same_connection_from_multiple_threads(tmpdir, io_method):
    conn = Model.open(tmpdir)

    with ThreadPoolExecutor(max_workers=1) as pool:
        res = pool.submit(getattr(conn, io_method))

    with pytest.raises(BadUsageError):
        res.result()
开发者ID:nilp0inter,项目名称:binlog,代码行数:10,代码来源:test_20_connection.py

示例10: test_list_readers

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_list_readers(readers):
    assume(len(readers & RESERVED_READER_NAMES) == 0)

    with TemporaryDirectory() as tmpdir:
        with Model.open(tmpdir) as db:
            for name in readers:
                db.register_reader(name)

            assert set(db.list_readers()) == readers
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_50_list_readers.py

示例11: test_ack_is_not_effective_before_commit

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_ack_is_not_effective_before_commit(tmpdir):
    with Model.open(tmpdir) as db:
        e0 = db.create(test='data0')

        db.register_reader('myreader')
        with db.reader('myreader') as reader1:
            reader1.ack(e0)
            with db.reader('myreader') as reader2:
                assert list(reader2)
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_60_ack_entries_and_reader.py

示例12: test_slice_negative_start_stop_step

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_slice_negative_start_stop_step(tmpdir, start, stop, step):
    with Model.open(tmpdir) as db:
        entries = [Model(idx=i) for i in range(4)]
        db.bulk_create(entries)

        with db.reader() as reader:
            expected = list(entries[start:stop:step])
            current = list(reader[start:stop:step])
            assert expected == current
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_45_reader_slicing.py

示例13: test_reader_reads_bulk_create

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_reader_reads_bulk_create(tmpdir):
    with Model.open(tmpdir) as db:
        entries = [Model(idx=i) for i in range(10)]
        db.bulk_create(entries)

        db.register_reader('myreader')
        with db.reader('myreader') as reader:
            for current, expected in zip_longest(reader, entries):
                assert current == expected
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_43_reader_iteration.py

示例14: test_can_remove_if_is_acked

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_can_remove_if_is_acked(tmpdir):
    with Model.open(tmpdir) as db:
        e0 = db.create(test='data0')

        db.register_reader('reader1')
        with db.reader('reader1') as reader:
            reader.ack(e0)

        assert db.remove(e0) is True
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_60_remove_entry.py

示例15: test_reader_index

# 需要导入模块: from binlog.model import Model [as 别名]
# 或者: from binlog.model.Model import open [as 别名]
def test_reader_index(tmpdir):
    with Model.open(tmpdir) as db:
        entries = [Model(idx=i) for i in range(10)]
        db.bulk_create(entries)

        db.register_reader('myreader')
        with db.reader('myreader') as reader:
            for e in entries:
                assert e == reader[e['idx']]
开发者ID:nilp0inter,项目名称:binlog,代码行数:11,代码来源:test_44_reader_get_index.py


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