def handle_directory_save(**kwargs): context = ( kwargs["instance"].parent if kwargs.get("created") else kwargs["instance"]) revision_updater.get(Directory)( context=context).update(keys=["stats", "checks"])
def test_revision_unit_updater(store0): assert revision_updater.get() is None unit = store0.units.first() updater_class = revision_updater.get(unit.__class__) assert updater_class is UnitRevisionUpdater updater = updater_class(object_list=store0.units) all_pootle_paths = updater.object_list.values_list( "store__parent__pootle_path", flat=True) assert (list(updater.all_pootle_paths) == list(set(all_pootle_paths))) assert (list(updater.parents) == list( Directory.objects.filter(pootle_path__in=updater.get_parent_paths( updater.all_pootle_paths))))
def lang_created_handler(**kwargs): if not kwargs.get("created"): return instance = kwargs["instance"] revision_context = instance.directory.parent updater = revision_updater.get(revision_context.__class__) updater(revision_context).update(["languages"])
def handle_directory_revision_update(**kwargs): updater = revision_updater.get(Directory) if kwargs.get("instance"): updater(context=kwargs["instance"]).update(keys=kwargs.get("keys")) else: updater(object_list=kwargs.get("object_list"), paths=kwargs.get("paths")).update(keys=kwargs.get("keys"))
def test_revision_unit_updater(store0): assert revision_updater.get() is None unit = store0.units.first() updater_class = revision_updater.get(unit.__class__) assert updater_class is UnitRevisionUpdater updater = updater_class(object_list=store0.units) all_pootle_paths = updater.object_list.values_list( "store__parent__pootle_path", flat=True) assert ( list(updater.all_pootle_paths) == list( set(all_pootle_paths))) assert ( list(updater.parents) == list( Directory.objects.filter( pootle_path__in=updater.get_parent_paths( updater.all_pootle_paths))))
def handle_vfolder_delete(sender, instance, **kwargs): dirs = set(instance.stores.values_list("parent", flat=True)) for store in instance.stores.all(): instance.stores.remove(store) if store.priority == instance.priority: store.set_priority() updater = revision_updater.get(Directory)( object_list=Directory.objects.filter(pk__in=dirs)) updater.update(keys=["stats"])
def handle_directory_revision_update(**kwargs): updater = revision_updater.get(Directory) if kwargs.get("instance"): updater(context=kwargs["instance"]).update( keys=kwargs.get("keys")) else: updater( object_list=kwargs.get("object_list"), paths=kwargs.get("paths")).update( keys=kwargs.get("keys"))
def test_revision_unit_updater_parent_paths(): updater_class = revision_updater.get(Unit) updater = updater_class([]) paths = updater.get_parent_paths([ "/foo/bar/path/foo.po", "/foo/bar2/path/foo.po", "/foo2/bar/path/foo.po", "/foo/bar/baz/some/other/baz.po" ]) assert (sorted(paths) == [ u"/foo/", u"/foo/bar/", u"/foo/bar/baz/", u"/foo/bar/baz/some/", u"/foo/bar/baz/some/other/", u"/foo/bar/path/", u"/foo/bar2/", u"/foo/bar2/path/", u"/foo2/", u"/foo2/bar/", u"/foo2/bar/path/", u"/projects/", u"/projects/bar/", u"/projects/bar2/" ])
def test_revision_unit_updater_parent_paths(): updater_class = revision_updater.get(Unit) updater = updater_class([]) paths = updater.get_parent_paths( ["/foo/bar/path/foo.po", "/foo/bar2/path/foo.po", "/foo2/bar/path/foo.po", "/foo/bar/baz/some/other/baz.po"]) assert ( sorted(paths) == [u"/foo/", u"/foo/bar/", u"/foo/bar/baz/", u"/foo/bar/baz/some/", u"/foo/bar/baz/some/other/", u"/foo/bar/path/", u"/foo/bar2/", u"/foo/bar2/path/", u"/foo2/", u"/foo2/bar/", u"/foo2/bar/path/", u"/projects/", u"/projects/bar/", u"/projects/bar2/"])
def test_revision_store_updater_update_single(store0): updater_class = revision_updater.get(Store) updater = updater_class(store0) _test_revision_updater(updater)
def handle_project_revision_update(**kwargs): revision_updater.get(Project)(context=kwargs["instance"]).update( keys=kwargs.get("keys"))
def handle_directory_delete(**kwargs): revision_updater.get(Directory)( context=kwargs["instance"].parent).update(keys=["stats", "checks"])
def handle_storedata_save(**kwargs): revision_updater.get(Store)( context=kwargs["instance"].store).update(keys=["stats", "checks"])
def test_revision_unit_updater_update_single(store0): updater_class = revision_updater.get(Unit) updater = updater_class(store0.units.select_related("store__parent").first()) _test_revision_updater(updater)
def test_revision_directory_updater_update(): updater_class = revision_updater.get(Directory) updater = updater_class( object_list=Directory.objects.filter(name="subdir0")) _test_revision_updater(updater)
def test_revision_directory_updater_single(subdir0): updater_class = revision_updater.get(Directory) updater = updater_class(subdir0) _test_revision_updater(updater)
def handle_tp_delete(**kwargs): revision_updater.get(Directory)( context=kwargs["instance"].directory).update(keys=["stats", "checks"])
def handle_store_revision_update(**kwargs): revision_updater.get(Store)( context=kwargs["instance"]).update(keys=kwargs.get("keys"))
def test_revision_unit_updater_update(store0): updater_class = revision_updater.get(Unit) updater = updater_class(object_list=store0.units) _test_revision_updater(updater)
def test_revision_directory_updater_update(): updater_class = revision_updater.get(Directory) updater = updater_class(object_list=Directory.objects.filter( name="subdir0")) _test_revision_updater(updater)
def test_revision_store_updater_update(tp0): updater_class = revision_updater.get(Store) updater = updater_class(object_list=tp0.stores) _test_revision_updater(updater)
def lang_delete_handler(**kwargs): instance = kwargs["instance"] revision_context = instance.directory.parent updater = revision_updater.get(revision_context.__class__) updater(revision_context).update(["languages"])
def handle_directory_save(**kwargs): if kwargs.get("created"): return revision_updater.get(Directory)( context=kwargs["instance"]).update(keys=["stats", "checks"])
def handle_store_revision_update(**kwargs): revision_updater.get(Store)(context=kwargs["instance"]).update( keys=kwargs.get("keys"))