def test_editors_cannot_publish_child_pages(root_page):
    env = two_branches_with_users(root_page)

    draft_page = ArticlePageFactory(
        parent=env.landing_1, live=False
    )
    revision = draft_page.save_revision(
        user=env.editor_1, submitted_for_moderation=True
    )

    resp = env.editor_1_client.post(
        reverse('wagtailadmin_pages:approve_moderation', args=[revision.pk])
    )
    assert resp.status_code == status.HTTP_403_FORBIDDEN
def test_moderators_and_admins_can_publish_child_pages(
        branch_factory, root_page
):
    branch = branch_factory.get(root_page)

    draft_page = ArticlePageFactory(parent=branch.listing, live=False)
    revision = draft_page.save_revision(
        user=branch.user, submitted_for_moderation=True,
    )

    resp = branch.client.post(
        reverse('wagtailadmin_pages:approve_moderation', args=[revision.pk])
    )
    assert resp.status_code == status.HTTP_302_FOUND
    assert resp.url == '/admin/'