def test_profile_add_course(auth_client, user, courses, session):
    newCourse = courses[0]
    resp = auth_client.patch("/profile/courses", data={ "course": newCourse.id })
    
    assert_api_success(resp)
    session.refresh(user)
    assert len(user.courses) > 0
Exemple #2
0
def test_profile_add_course(auth_client, user, courses, session):
    newCourse = courses[0]
    resp = auth_client.patch("/profile/courses", data={"course": newCourse.id})

    assert_api_success(resp)
    session.refresh(user)
    assert len(user.courses) > 0
def test_profile_delete_course(auth_client, user_with_courses, session):
    existingCourse = user_with_courses.courses[0]
    resp = auth_client.delete("/profile/courses", data={ "course": existingCourse.id })

    assert_api_success(resp)
    session.refresh(user_with_courses)
    assert len(user_with_courses.courses) == 4
    assert not find(user_with_courses.courses, lambda mod: mod.id == existingCourse.id)
Exemple #4
0
def test_profile_delete_course(auth_client, user_with_courses, session):
    existingCourse = user_with_courses.courses[0]
    resp = auth_client.delete("/profile/courses",
                              data={"course": existingCourse.id})

    assert_api_success(resp)
    session.refresh(user_with_courses)
    assert len(user_with_courses.courses) == 4
    assert not find(user_with_courses.courses,
                    lambda mod: mod.id == existingCourse.id)
def test_profile_add_course_existing(auth_client, user_with_courses, session):
    existingCourse = user_with_courses.courses[0]
    resp = auth_client.patch("/profile/courses", data={ "course": existingCourse.id })

    # This is intended behaviour because if the user already has the
    # course associated, then this request will *always* be a success
    # It's up to the client to notice that the user already has the
    # course associated.
    assert_api_success(resp) 
    session.refresh(user_with_courses)
    assert len(user_with_courses.courses) == 5
Exemple #6
0
def test_profile_add_course_existing(auth_client, user_with_courses, session):
    existingCourse = user_with_courses.courses[0]
    resp = auth_client.patch("/profile/courses",
                             data={"course": existingCourse.id})

    # This is intended behaviour because if the user already has the
    # course associated, then this request will *always* be a success
    # It's up to the client to notice that the user already has the
    # course associated.
    assert_api_success(resp)
    session.refresh(user_with_courses)
    assert len(user_with_courses.courses) == 5