예제 #1
0
def test_recordinfo_children_sort_limited_alts(project, env):
    # This excercises the bug described in #962, namely that
    # if a page has a child that only has content in a subset of the
    # configured alts, get_record_info throws an exception.
    webadmin = WebAdmin(env, output_path=project.tree)
    data = json.loads(webadmin.test_client().get(
        "/admin/api/recordinfo?path=/projects").data)
    child_data = data["children"]
    assert list(sorted(child_data, key=itemgetter("label"))) == child_data
예제 #2
0
def test_children_sorting_via_api(scratch_project, scratch_env, children_records_data):
    webadmin = WebAdmin(scratch_env, output_path=scratch_project.tree)
    data = json.loads(webadmin.test_client().get('/admin/api/recordinfo?path=/myobj').data)
    children_records_ids_provided_by_api = list(map(itemgetter('id'), data['children']))

    records_ordered_by_title = sorted(children_records_data, key=itemgetter('title'))
    ordered_records = sorted(records_ordered_by_title, key=itemgetter('pub_date'), reverse=True)

    assert list(map(itemgetter('id'), ordered_records)) == children_records_ids_provided_by_api