Пример #1
0
def test_submission_correct_response_fibonacci(db, user, request_with_user):
    question = example('fibonacci')
    src = source('fibonacci.py')
    submission = question.submit(request_with_user,
                                 source=src,
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is True
Пример #2
0
def test_submission_correct_response_fibonacci(db, user, request_with_user):
    question = example('fibonacci')
    src = source('fibonacci.py')
    submission = question.submit(request_with_user,
                                 source=src,
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is True
Пример #3
0
def test_submission_feedback_keeps_the_correct_code_hello(
        db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-build.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    db_fb = Feedback.objects.get(id=submission.id)
    assert feedback.feedback_status == db_fb.feedback.status
Пример #4
0
def test_submission_feedback_keeps_the_correct_code_hello(db, user,
                                                          request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-build.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    db_fb = Feedback.objects.get(id=submission.id)
    assert feedback.feedback_status == db_fb.feedback.status
Пример #5
0
def test_submission_with_runtime_error_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-runtime.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'runtime-error'
    assert feedback.is_runtime_error
    assert feedback.final_grade_pc == 0
Пример #6
0
def test_submission_with_wrong_answer_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-wrong.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'wrong-answer'
    assert feedback.is_wrong_answer
    assert feedback.final_grade_pc == 0
Пример #7
0
def test_submission_with_presentation_error_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-presentation.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'presentation-error'
    assert feedback.is_presentation_error
    assert feedback.given_grade_pc < 100
Пример #8
0
def test_submission_correct_response_hello(db, user, request_with_user):
    question = example('simple')
    src = source('hello.py')
    submission = question.submit(request_with_user,
                                 source=src,
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.given_grade_pc == 100
    assert feedback.final_grade_pc == 100
    assert feedback.is_correct is True
Пример #9
0
def test_submission_correct_response_hello(db, user, request_with_user):
    question = example('simple')
    src = source('hello.py')
    submission = question.submit(request_with_user,
                                 source=src,
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.given_grade_pc == 100
    assert feedback.final_grade_pc == 100
    assert feedback.is_correct is True
Пример #10
0
def test_submission_with_invalid_syntax_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-build.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'build-error'
    assert feedback.is_build_error
    assert feedback.final_grade_pc == 0
Пример #11
0
def test_submission_with_runtime_error_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-runtime.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'runtime-error'
    assert feedback.is_runtime_error
    assert feedback.final_grade_pc == 0
Пример #12
0
def test_submission_with_wrong_answer_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-wrong.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'wrong-answer'
    assert feedback.is_wrong_answer
    assert feedback.final_grade_pc == 0
Пример #13
0
def test_submission_with_presentation_error_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-presentation.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'presentation-error'
    assert feedback.is_presentation_error
    assert feedback.given_grade_pc < 100
Пример #14
0
def test_submission_with_invalid_syntax_hello(db, user, request_with_user):
    question = example('simple')
    submission = question.submit(request_with_user,
                                 source=source('hello-build.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'build-error'
    assert feedback.is_build_error
    assert feedback.final_grade_pc == 0
Пример #15
0
def test_hello_question_creation(db):
    question = example('hello')
    question.full_clean_all()
    assert question.get_reference_source('python') == source(
        'hello.py').strip()
    assert question.title == 'Hello Person'
    assert question.pre_tests is not None
    assert question.pre_tests.is_expanded is True
    assert question.post_tests is not None
    assert question.post_tests.is_expanded is False
    assert question.answers.count() == 1
Пример #16
0
def test_hello_question_creation(db):
    question = example('hello')
    question.full_clean_all()
    assert question.get_reference_source(
        'python') == source('hello.py').strip()
    assert question.title == 'Hello Person'
    assert question.pre_tests is not None
    assert question.pre_tests.is_expanded is True
    assert question.post_tests is not None
    assert question.post_tests.is_expanded is False
    assert question.answers.count() == 1
Пример #17
0
def test_stop_execution_of_submission_after_timeout_hello(db, user,
                                                          request_with_user):
    question = example('simple')
    question.timeout = 0.35

    submission = question.submit(request_with_user,
                                 source=source('hello-timeout.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'timeout-error'
    assert feedback.is_timeout_error
    assert feedback.final_grade_pc == 0
Пример #18
0
def test_stop_execution_of_submission_after_timeout_hello(
        db, user, request_with_user):
    question = example('simple')
    question.timeout = 0.35

    submission = question.submit(request_with_user,
                                 source=source('hello-timeout.py'),
                                 language='python')
    feedback = submission.auto_feedback()
    assert feedback.is_correct is False
    assert feedback.feedback_status == 'timeout-error'
    assert feedback.is_timeout_error
    assert feedback.final_grade_pc == 0
Пример #19
0
def test_dump_markio_exports_successfully(db):
    question = example('simple')
    md_source = question.dump_markio()
    md = parse_markio(source('simple.md'))
    assert md_source == md.source()