Ejemplo n.º 1
0
def test_get_root(app_router, registry):
    from adhocracy_core.utils import get_root
    fake_root = testing.DummyResource()
    app_router.root_factory = Mock()
    app_router.root_factory.return_value = fake_root
    root = get_root(app_router)
    assert root == fake_root
Ejemplo n.º 2
0
def test_get_root(app, registry):
    from adhocracy_core.resources.root import IRootPool
    from adhocracy_core.utils import get_root
    fake_root = testing.DummyResource()
    app.root_factory = Mock()
    app.root_factory.return_value = fake_root
    root = get_root(app)
    assert root == fake_root
Ejemplo n.º 3
0
def test_get_root(app, registry):
    from adhocracy_core.resources.root import IRootPool
    from adhocracy_core.utils import get_root
    fake_root = testing.DummyResource()
    app.root_factory = Mock()
    app.root_factory.return_value = fake_root
    root = get_root(app)
    assert root == fake_root
Ejemplo n.º 4
0
def set_acms_for_app_root(app: Router, acms: (dict)=()):
    """
    Set the :term:`acm`s for the `app`s root object.

    In addition all permissions are granted the god user.

    :param app: The pyramid wsgi application
    :param acms: :class:`adhocracy_core.schema.ACM` dictionaries.
                 :term:`acm`s with overriding permissions should be put
                 before :term:`acm`s with default permissions.
    """
    new_acl = [god_all_permission_ace]
    for acm in acms:
        new_acl += acm_to_acl(acm, app.registry)
    root = get_root(app)
    old_acl = get_acl(root)
    if old_acl == new_acl:
        return
    set_acl(root, new_acl, app.registry)
    transaction.commit()
Ejemplo n.º 5
0
def set_acms_for_app_root(app: Router, acms: (dict) = ()):
    """
    Set the :term:`acm`s for the `app`s root object.

    In addition all permissions are granted the god user.

    :param app: The pyramid wsgi application
    :param acms: :class:`adhocracy_core.schema.ACM` dictionaries.
                 :term:`acm`s with overriding permissions should be put
                 before :term:`acm`s with default permissions.
    """
    new_acl = [god_all_permission_ace]
    for acm in acms:
        new_acl += acm_to_acl(acm, app.registry)
    root = get_root(app)
    old_acl = get_acl(root)
    if old_acl == new_acl:
        return
    set_acl(root, new_acl, app.registry)
    transaction.commit()
Ejemplo n.º 6
0
def add_resources(app: Router, filename: str):
    """Add resources from a JSON file to the app."""
    root = get_root(app)
    import_resources(root, app.registry, filename)
    transaction.commit()
Ejemplo n.º 7
0
def add_resources(app_router: Router, filename: str):
    """Add resources from a JSON file to the app."""
    root = get_root(app_router)
    import_resources(root, app_router.registry, filename)
    transaction.commit()