Beispiel #1
0
def test_custom_detail_page_urls():
    """Verify that course/external-course/program detail pages return our custom URL path"""
    readable_id = "some:readable-id"
    external_readable_id = "some:external-readable-id"
    program_pages = ProgramPageFactory.create_batch(
        2,
        program__readable_id=factory.Iterator([readable_id,
                                               "non-matching-id"]))
    external_program_pages = ExternalProgramPageFactory.create_batch(
        2,
        readable_id=factory.Iterator([readable_id,
                                      "non-matching-external-id"]))
    course_pages = CoursePageFactory.create_batch(
        2,
        course__readable_id=factory.Iterator([readable_id, "non-matching-id"]))
    external_course_pages = ExternalCoursePageFactory.create_batch(
        2,
        readable_id=factory.Iterator(
            [external_readable_id, "non-matching-external-id"]),
    )
    assert program_pages[0].get_url() == "/programs/{}/".format(readable_id)
    assert external_program_pages[0].get_url() == "/programs/{}/".format(
        readable_id)
    assert course_pages[0].get_url() == "/courses/{}/".format(readable_id)
    assert external_course_pages[0].get_url() == "/courses/{}/".format(
        external_readable_id)
Beispiel #2
0
def test_program_course_order():
    """
    The course pages in program page should be ordered on the basis of position_in_program
    """
    program_page = ProgramPageFactory.create()
    course_pages = CoursePageFactory.create_batch(
        3,
        course__position_in_program=factory.Iterator([2, 3, 1]),
        course__program=program_page.program,
    )
    single_course_page = course_pages[0]
    assert [
        course_page.course.position_in_program
        for course_page in single_course_page.course_pages
    ] == [1, 2, 3]
    assert [
        course_page.course.position_in_program
        for course_page in program_page.course_pages
    ] == [1, 2, 3]