Example #1
0
def test_course_details_delete():
    # Superuser and write perms
    dummy_access_fn.__module__ = "course_details"
    dummy_access_fn.__name__ = "delete"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("write") and perms.get("superuser"):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)()
        assert has_access == ret_code
Example #2
0
def test_gpa_cards_get():
    # Levels and read perms
    dummy_access_fn.__module__ = "gpa_cards"
    dummy_access_fn.__name__ = "get"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and (400 in perms.get("levels", [])
                                  or perms.get("superuser")):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)(level=400)
        assert has_access == ret_code
Example #3
0
def test_course_reg_init_new():
    # Levels and read perms
    dummy_access_fn.__module__ = "course_reg"
    dummy_access_fn.__name__ = "init_new"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and (400 in perms.get("levels", [])
                                  or perms.get("superuser")):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)(
            mat_no=student_400, acad_session=2019)
        assert has_access == ret_code
Example #4
0
def test_personal_info_post():
    # Levels & write perms
    dummy_access_fn.__module__ = "personal_info"
    dummy_access_fn.__name__ = "post_exp"
    student_data = {"mat_no": "ENG1603123", "level": 400}
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("write") and (student_data["level"] in perms.get(
                "levels", []) or perms.get("superuser")):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)(data=student_data)
        assert has_access == ret_code
Example #5
0
def test_personal_info_get():
    # Levels & read perms
    dummy_access_fn.__module__ = "personal_info"
    dummy_access_fn.__name__ = "get_exp"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and (400 in perms.get("levels", [])
                                  or perms.get("superuser")):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)(
            mat_no=student_400)
        assert has_access == ret_code
Example #6
0
def test_course_reg_put():
    # Superuser and write perms
    dummy_access_fn.__module__ = "course_reg"
    dummy_access_fn.__name__ = "put"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("write") and perms.get("superuser"):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = access_decorator(dummy_access_fn)(
            data={
                "mat_no": student_400
            })
        assert has_access == ret_code