Esempio n. 1
0
def test_panel_project_store_table(project0, store0, rf, member):
    request = rf.get("/projects/project0/store0")
    request.user = member
    request.permissions = get_matching_permissions(request.user, project0.directory.parent)
    view = ProjectBrowseView(kwargs=dict(project_code=project0.code, dir_path="", filename=store0.name))
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectBrowseView)
    assert lang_panels.keys() == ["children"]
    assert lang_panels["children"] == ChildrenPanel
    panel = ChildrenPanel(view)
    assert panel.panel_name == "children"
    assert panel.cache_key == ("panel.%s.%s" % (panel.panel_name, view.cache_key))

    table = {
        "id": view.view_name,
        "fields": panel.table_fields,
        "headings": get_table_headings(panel.table_fields),
        "rows": view.object_children,
    }

    assert panel.table == table
    assert panel.get_context_data() == dict(table=table, can_translate=view.can_translate)
    content = loader.render_to_string(panel.template_name, context=panel.get_context_data())
    assert panel.content == panel.update_times(content)
Esempio n. 2
0
def test_panel_project_store_table(project0, store0, rf, member):
    request = rf.get('/projects/project0/store0')
    request.user = member
    view = ProjectBrowseView(kwargs=dict(
        project_code=project0.code, dir_path="", filename=store0.name))
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectBrowseView)
    assert lang_panels.keys() == ["children"]
    assert lang_panels["children"] == ChildrenPanel
    panel = ChildrenPanel(view)
    assert panel.panel_name == "children"
    assert (panel.cache_key == ("panel.%s.%s" %
                                (panel.panel_name, view.cache_key)))

    table = {
        'id': view.view_name,
        'fields': panel.table_fields,
        'headings': get_table_headings(panel.table_fields),
        'items': view.items,
        'disabled_items': view.disabled_items
    }

    assert panel.table == table
    assert panel.get_context_data() == dict(table=table)
    assert (panel.content == loader.render_to_string(panel.template_name,
                                                     panel.get_context_data()))
Esempio n. 3
0
def test_view_project_store_children(project0, store0, rf, request_users):
    request = rf.get('/projects/project0/store0.po')
    request.user = request_users["user"]
    view = ProjectBrowseView(kwargs=dict(
        project_code=project0.code, dir_path="", filename=store0.name))
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectResource)
    _test_view_project_children(view, project0)
Esempio n. 4
0
def test_view_project_subdir_children(project0, subdir0, rf, request_users):
    request = rf.get('/projects/project0/subdir0/')
    request.user = request_users["user"]
    view = ProjectBrowseView(kwargs=dict(
        project_code=project0.code, dir_path=subdir0.tp_path[1:], filename=""))
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectResource)
    _test_view_project_children(view, project0)
Esempio n. 5
0
def test_view_project_children(project0, rf, request_users):
    request = rf.get('/projects/project0/')
    request.user = request_users["user"]
    view = ProjectBrowseView(
        kwargs=dict(project_code=project0.code, dir_path="", filename=""))
    view.request = request
    view.object = view.get_object()
    assert view.object == project0
    _test_view_project_children(view, project0)
Esempio n. 6
0
def test_view_project_store_children(project0, store0, rf, request_users):
    request = rf.get('/projects/project0/store0.po')
    request.user = request_users["user"]
    view = ProjectBrowseView(
        kwargs=dict(
            project_code=project0.code,
            dir_path="",
            filename=store0.name))
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectResource)
    _test_view_project_children(view, project0)
Esempio n. 7
0
def test_view_project_subdir_children(project0, subdir0, rf, request_users):
    request = rf.get('/projects/project0/subdir0/')
    request.user = request_users["user"]
    view = ProjectBrowseView(
        kwargs=dict(
            project_code=project0.code,
            dir_path=subdir0.tp_path[1:],
            filename=""))
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectResource)
    _test_view_project_children(view, project0)
Esempio n. 8
0
def test_view_project_children(project0, rf, request_users):
    request = rf.get('/projects/project0/')
    request.user = request_users["user"]
    view = ProjectBrowseView(
        kwargs=dict(
            project_code=project0.code,
            dir_path="",
            filename=""))
    view.request = request
    view.object = view.get_object()
    assert view.object == project0
    _test_view_project_children(view, project0)
Esempio n. 9
0
def test_panel_project_store_table(project0, store0, rf, member):
    request = rf.get('/projects/project0/store0')
    request.user = member
    request.permissions = get_matching_permissions(
        request.user,
        project0.directory.parent)
    view = ProjectBrowseView(
        kwargs=dict(
            project_code=project0.code,
            dir_path="",
            filename=store0.name))
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectBrowseView)
    assert lang_panels.keys() == ["children"]
    assert lang_panels["children"] == ChildrenPanel
    panel = ChildrenPanel(view)
    assert panel.panel_name == "children"
    assert (
        panel.cache_key
        == ("panel.%s.%s"
            % (panel.panel_name, view.cache_key)))

    table = {
        'id': view.view_name,
        'fields': panel.table_fields,
        'headings': get_table_headings(panel.table_fields),
        'rows': view.object_children}

    assert panel.table == table
    assert panel.get_context_data() == dict(
        table=table, can_translate=view.can_translate)
    content = loader.render_to_string(
        panel.template_name, context=panel.get_context_data())
    assert (
        panel.content
        == panel.update_times(content))