def _setup_store_test(store, member, test): setup = test.get("setup", DEFAULT_STORE_TEST_SETUP) 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 = test["store_revision"] units_before_update = [ unit for unit in store.unit_set.all().order_by("index") ] if store_revision == "MAX": store_revision = store.get_max_unit_revision() elif store_revision == "MID": revisions = [unit.revision for unit in units_before_update] store_revision = sum(revisions) / len(revisions) return { "store": store, "units_in_file": test["units_in_file"], "store_revision": store_revision, "units_before_update": units_before_update, }
def _setup_store_test(store, member, test): setup = test.get('setup', DEFAULT_STORE_TEST_SETUP) 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 = test['store_revision'] units_before_update = [ unit for unit in store.unit_set.all().order_by('index') ] if store_revision == "MAX": store_revision = store.get_max_unit_revision() elif store_revision == "MID": revisions = [unit.revision for unit in units_before_update] store_revision = sum(revisions) / len(revisions) return { 'store': store, 'units_in_file': test['units_in_file'], 'store_revision': store_revision, 'units_before_update': units_before_update, }
def param_update_store_test(request, tp0, member, member2): from tests.factories import StoreDBFactory store = StoreDBFactory(translation_project=tp0, parent=tp0.directory) test = _setup_store_test(store, member, UPDATE_STORE_TESTS[request.param]) update_store( test["store"], units=test["units_in_file"], store_revision=test["store_revision"], user=member2, ) return test
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