コード例 #1
0
def test_wagtail_bakery_pages_api_listing_view_build_path_for_multisite(
        multisite):
    view = PagesAPIListingView()

    # Check build path for homepage
    build_path = view.get_build_path(0)
    assert build_path == 'api/pages/0.json'
コード例 #2
0
def test_wagtail_bakery_pages_api_listing_view():
    view = PagesAPIListingView()

    # Check build path
    build_path = view.get_build_path(0)
    assert build_path == 'api/pages/0.json'

    # Check build path for second page
    build_path = view.get_build_path(1)
    assert build_path == 'api/pages/1.json'
コード例 #3
0
def test_wagtail_bakery_pages_api_listing_view_content(page_tree):
    view = PagesAPIListingView()

    # Check content
    content = json.loads(view.get_content(0)[0].decode('UTF-8'))
    assert set(content.keys()) == {'meta', 'items'}
    assert set(content['meta'].keys()) == {'total_count'}

    page = content['items'][0]
    assert set(page.keys()) == DEFAULT_PAGE_FIELDS
    assert set(page['meta'].keys()) == DEFAULT_PAGE_META_FIELDS