本文整理汇总了Python中pytest_pootle.utils.update_store函数的典型用法代码示例。如果您正苦于以下问题:Python update_store函数的具体用法?Python update_store怎么用?Python update_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_store函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"
示例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
示例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)
示例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
示例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)
示例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
示例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)
示例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)
示例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
示例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
示例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"
示例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
示例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"
示例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)
示例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