• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.update_store函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pytest_pootle.utils.update_store函数的典型用法代码示例。如果您正苦于以下问题:Python update_store函数的具体用法?Python update_store怎么用?Python update_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_update_upload_new_revision

def test_update_upload_new_revision(en_tutorial_po):
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world UPDATED")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=Revision.get() + 1)
    assert en_tutorial_po.units[0].target == "Hello, world UPDATED"
开发者ID:AshishNamdev,项目名称:pootle,代码行数:7,代码来源:store.py


示例2: test_update_upload_member_user

def test_update_upload_member_user(en_tutorial_po, member):
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world UPDATED")],
        user=member,
        store_revision=Revision.get() + 1)
    assert en_tutorial_po.units[0].submitted_by == member
开发者ID:AshishNamdev,项目名称:pootle,代码行数:7,代码来源:store.py


示例3: test_update_upload_submission_type

def test_update_upload_submission_type(en_tutorial_po):
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world UPDATED")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=Revision.get() + 1)
    assert (en_tutorial_po.units[0].submission_set.first().type
            == SubmissionTypes.UPLOAD)
开发者ID:AshishNamdev,项目名称:pootle,代码行数:8,代码来源:store.py


示例4: test_update_upload_member_user

def test_update_upload_member_user(store0, member):
    store0.state = PARSED
    unit_source = store0.units.first().source
    update_store(
        store0,
        [(unit_source, "%s UPDATED" % unit_source)],
        user=member,
        store_revision=Revision.get() + 1)
    assert store0.units[0].submitted_by == member
开发者ID:SafaAlfulaij,项目名称:pootle,代码行数:9,代码来源:store.py


示例5: test_update_upload_defaults

def test_update_upload_defaults(en_tutorial_po, system):
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world UPDATED")],
        user=system,
        store_revision=Revision.get() + 1)
    assert en_tutorial_po.units[0].submitted_by == system
    assert (en_tutorial_po.units[0].submission_set.first().type
            == SubmissionTypes.SYSTEM)
开发者ID:AshishNamdev,项目名称:pootle,代码行数:9,代码来源:store.py


示例6: param_update_store_test

def param_update_store_test(request, en_tutorial_po, member, member2):
    test = _setup_store_test(en_tutorial_po, member, member2,
                             UPDATE_STORE_TESTS[request.param])
    update_store(test[0],
                 units=test[1],
                 store_revision=test[2],
                 user=member2,
                 resolve_conflict=test[3])
    return test
开发者ID:Finntack,项目名称:pootle,代码行数:9,代码来源:store.py


示例7: test_update_upload_submission_type

def test_update_upload_submission_type(store0):
    store0.state = PARSED
    unit_source = store0.units.first().source
    update_store(
        store0,
        [(unit_source, "%s UPDATED" % unit_source)],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=Revision.get() + 1)
    assert (
        store0.units[0].submission_set.last().type
        == SubmissionTypes.UPLOAD)
开发者ID:SafaAlfulaij,项目名称:pootle,代码行数:11,代码来源:store.py


示例8: test_update_upload_defaults

def test_update_upload_defaults(store0, system):
    store0.state = PARSED
    unit_source = store0.units.first().source
    update_store(
        store0,
        [(unit_source, "%s UPDATED" % unit_source)],
        user=system,
        store_revision=Revision.get() + 1)
    assert store0.units[0].submitted_by == system
    assert (
        store0.units[0].submission_set.last().type
        == SubmissionTypes.SYSTEM)
开发者ID:SafaAlfulaij,项目名称:pootle,代码行数:12,代码来源:store.py


示例9: param_update_store_test

def param_update_store_test(request, tp0, member, member2):
    from pootle.core.contextmanagers import update_data_after

    store = StoreDBFactory(
        translation_project=tp0,
        parent=tp0.directory)
    with update_data_after(store):
        test = _setup_store_test(
            store, member, member2,
            UPDATE_STORE_TESTS[request.param])
        update_store(
            test[0],
            units=test[1],
            store_revision=test[2],
            user=member2,
            resolve_conflict=test[3])
    return test
开发者ID:SafaAlfulaij,项目名称:pootle,代码行数:17,代码来源:store.py


示例10: _create_submission_and_suggestion

def _create_submission_and_suggestion(store, user,
                                      units=None,
                                      suggestion="SUGGESTION"):

    from pootle.core.models import Revision

    # Update store as user
    if units is None:
        units = [("Hello, world", "Hello, world UPDATED")]
    update_store(
        store,
        units,
        user=user,
        store_revision=Revision.get() + 1)

    # Add a suggestion
    unit = store.units[0]
    unit.add_suggestion(suggestion, user=user)
    return unit
开发者ID:Finntack,项目名称:pootle,代码行数:19,代码来源:store.py


示例11: test_update_upload_again_new_revision

def test_update_upload_again_new_revision(en_tutorial_po_no_file):
    store = en_tutorial_po_no_file
    assert store.state == NEW
    update_store(
        store,
        [("Hello, world", "Hello, world UPDATED")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=Revision.get() + 1)
    store = Store.objects.get(pk=store.pk)
    assert store.state == PARSED
    assert store.units[0].target == "Hello, world UPDATED"

    update_store(
        store,
        [("Hello, world", "Hello, world UPDATED AGAIN")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=Revision.get() + 1)
    store = Store.objects.get(pk=store.pk)
    assert store.state == PARSED
    assert store.units[0].target == "Hello, world UPDATED AGAIN"
开发者ID:AshishNamdev,项目名称:pootle,代码行数:20,代码来源:store.py


示例12: _create_submission_and_suggestion

def _create_submission_and_suggestion(store, user,
                                      units=None,
                                      suggestion="SUGGESTION"):
    from pootle.core.delegate import review
    from pootle.core.models import Revision
    from pootle_store.models import Suggestion

    # Update store as user
    if units is None:
        units = [("Hello, world", "Hello, world UPDATED", False)]
    update_store(
        store,
        units,
        user=user,
        store_revision=Revision.get() + 1)

    # Add a suggestion
    unit = store.units[0]
    review.get(Suggestion)().add(unit, suggestion, user)
    return unit
开发者ID:arky,项目名称:pootle,代码行数:20,代码来源:store.py


示例13: test_update_upload_old_revision_unit_conflict

def test_update_upload_old_revision_unit_conflict(en_tutorial_po):
    original_revision = Revision.get()
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world UPDATED")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=original_revision + 1)

    # load update with expired revision and conflicting unit
    update_store(
        en_tutorial_po,
        [("Hello, world", "Hello, world CONFLICT")],
        submission_type=SubmissionTypes.UPLOAD,
        store_revision=original_revision)

    # unit target is not updated
    assert en_tutorial_po.units[0].target == "Hello, world UPDATED"

    # but suggestion is added
    suggestion = en_tutorial_po.units[0].get_suggestions()[0].target
    assert suggestion == "Hello, world CONFLICT"
开发者ID:AshishNamdev,项目名称:pootle,代码行数:21,代码来源:store.py


示例14: _setup_store_test

def _setup_store_test(store, member, member2, test):
    from pootle_store.constants import POOTLE_WINS, SOURCE_WINS

    setup = test.get("setup", None)

    if setup is None:
        setup = [(DEFAULT_STORE_UNITS_1),
                 (DEFAULT_STORE_UNITS_1 + DEFAULT_STORE_UNITS_2)]

    for units in setup:
        store_revision = store.get_max_unit_revision()
        print("setup store: %s %s" % (store_revision, units))
        update_store(store, store_revision=store_revision, units=units,
                     user=member)
        for unit in store.units:
            comment = ("Set up unit(%s) with store_revision: %s"
                       % (unit.source_f, store_revision))
            _create_comment_on_unit(unit, member, comment)

    store_revision, units_update = test["update_store"]
    units_before = [
        (unit, unit.change)
        for unit in store.unit_set.select_related("change").all().order_by("index")]

    fs_wins = test.get("fs_wins", True)
    if fs_wins:
        resolve_conflict = SOURCE_WINS
    else:
        resolve_conflict = POOTLE_WINS

    if store_revision == "MAX":
        store_revision = store.get_max_unit_revision()

    elif store_revision == "MID":
        revisions = [unit.revision for unit, change in units_before]
        store_revision = sum(revisions) / len(revisions)

    return (store, units_update, store_revision, resolve_conflict,
            units_before, member, member2)
开发者ID:ta2-1,项目名称:pootle,代码行数:39,代码来源:store.py


示例15: param_update_store_test

def param_update_store_test(request, tp0, member, member2):
    from pootle.core.contextmanagers import keep_data
    from pootle.core.signals import update_data

    store = StoreDBFactory(
        translation_project=tp0,
        parent=tp0.directory)

    with keep_data():
        test = _setup_store_test(
            store, member, member2,
            UPDATE_STORE_TESTS[request.param])
    update_data.send(store.__class__, instance=store)

    with keep_data():
        update_store(
            test[0],
            units=test[1],
            store_revision=test[2],
            user=member2,
            resolve_conflict=test[3])
    update_data.send(store.__class__, instance=store)

    return test
开发者ID:arky,项目名称:pootle,代码行数:24,代码来源:store.py


示例16: git_env

def git_env(post_db_setup, _django_cursor_wrapper):
    from django.conf import settings

    from pytest_pootle.utils import update_store
    from pytest_pootle.fs.utils import create_test_suite
    import pytest_pootle

    from pytest_pootle.factories import (
        ProjectDBFactory, TranslationProjectFactory)

    from pootle_app.models import Directory
    from pootle_config.utils import ObjectConfig
    from pootle_fs.plugin import FSPlugin
    from pootle_language.models import Language
    from pootle_store.models import Store

    import tempfile

    with _django_cursor_wrapper:
        project0 = ProjectDBFactory(
            source_language=Language.objects.get(code="en"),
            code="git_project_0")

        language0 = Language.objects.get(code="language0")
        tp = TranslationProjectFactory(project=project0, language=language0)

        initial_src_path = os.path.abspath(
            os.path.join(
                os.path.dirname(pytest_pootle.__file__),
                "data/fs/example_fs"))
        fs_dir = tempfile.mkdtemp()
        settings.POOTLE_FS_PATH = fs_dir

        repo_path = os.path.join(fs_dir, "__git_src_project_0__")
        Repo.init(repo_path, bare=True)

        with tmp_git(repo_path) as (tmp_repo_path, tmp_repo):
            with get_dir_util() as dir_util:
                dir_util.copy_tree(initial_src_path, tmp_repo_path)
            tmp_repo.index.add([".pootle.ini", "*"])
            tmp_repo.index.commit("Initial commit")
            tmp_repo.remotes.origin.push("master:master")

        conf = ObjectConfig(project0)
        conf["pootle_fs.fs_type"] = "git"
        conf["pootle_fs.fs_url"] = repo_path
        conf["pootle_fs.translation_paths"] = OrderedDict(
            [("default", "gnu_style/po/<lang>.po"),
             ("subdir1",
              "gnu_style_named_folders/po-<filename>/<lang>.po"),
             ("subdir2",
              "gnu_style_named_files/po/<filename>-<lang>.po"),
             ("subdir3",
              "non_gnu_style/locales/<lang>/<directory_path>/<filename>.po")])

        updated_src_path = os.path.abspath(
            os.path.join(
                os.path.dirname(pytest_pootle.__file__),
                "data/fs/example_fs_updated"))

        plugin = FSPlugin(project0)
        plugin.add_translations()
        plugin.fetch_translations()
        plugin.sync_translations()

        with tmp_git(repo_path) as (tmp_repo_path, tmp_repo):
            # merge the update onto the repo src
            with get_dir_util() as dir_util:
                dir_util.copy_tree(
                    updated_src_path,
                    tmp_repo_path, preserve_times=0)
            tmp_repo.index.add([".pootle.ini", "*"])
            tmp_repo.index.commit("Creating test suite")
            tmp_repo.remotes.origin.push("master:master")

        # conflict
        pootle_path_conflict = (
            "%ssubdir3/subsubdir/example3.po"
            % tp.pootle_path)
        plugin.pull()
        update_store(
            Store.objects.get(pootle_path=pootle_path_conflict),
            units=(("Hello, world", "Hello, world DB CONFLICT"), ))

        # conflict_untracked
        subdir3 = Directory.objects.get(
            pootle_path="%ssubdir3/" % tp.pootle_path)
        Store.objects.create(
            translation_project=tp,
            parent=subdir3,
            name="example3.po")

        # pootle_ahead
        pootle_path_ahead = "%ssubdir1/example1.po" % tp.pootle_path
        update_store(
            Store.objects.get(pootle_path=pootle_path_ahead),
            units=(("Hello, world", "Hello, world DB AHEAD"), ))

        # pootle_untracked
        Store.objects.create(
#.........这里部分代码省略.........
开发者ID:translate,项目名称:pootle_fs_git,代码行数:101,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pytest_ringo.login函数代码示例发布时间:2022-05-27
下一篇:
Python utils.create_api_request函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap