示例#1
0
def test_panel_projects_table(rf, member, project0):
    request = rf.get("/projects/")
    request.user = member
    request.permissions = get_matching_permissions(request.user, project0.directory.parent)
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectsBrowseView)
    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)
示例#2
0
def test_panel_projects_table(rf, member, project0):
    request = rf.get('/projects/')
    request.user = member
    request.permissions = get_matching_permissions(
        request.user,
        project0.directory.parent)
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectsBrowseView)
    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))
示例#3
0
def test_panel_projects_table(rf, member):
    request = rf.get('/projects/')
    request.user = member
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    lang_panels = panels.gather(ProjectsBrowseView)
    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()))
示例#4
0
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project) for project in view.object.children
    ]
    view.add_child_stats(items)
    items.sort(cmp_by_last_activity)
    assert view.object_children == items
示例#5
0
文件: views.py 项目: cloph/pootle
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project)
        for project
        in view.object.children]
    view.add_child_stats(items)
    items.sort(cmp_by_last_activity)
    assert view.object_children == items
示例#6
0
文件: views.py 项目: ainslied/pootle
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project)
        for project
        in view.object.children]
    items.sort(
        lambda x, y: locale.strcoll(x['title'], y['title']))
    view.add_child_stats(items)
    assert view.object_children == items