Example #1
0
    def test_has_questions(self):
        trquestion1 = {
            'questionID': 1,
            'correctOption': "A",
            'correctOptionText': "text"
        }
        question1 = {
            'questionID': 1,
            'selectedOption': "A",
        }
        taskResponse = Mock()
        taskResponse.graded_response = False
        taskResponse.response = json.dumps({
            'automatic_questions': [question1],
            'manual_questions': []
        })
        taskResponse.correctness_grade = None
        taskResponse.task = Mock()
        taskResponse.task.questions = json.dumps([trquestion1])
        self.models.TaskResponse.query.filter_by.return_value.first.return_value = taskResponse
        grader = grading.Grader()
        grader.calculate_correctness = Mock()
        grader.calculate_correctness.return_value = "grade"

        ret = grader.grade_automatic_questions(1)
        self.assertEqual(taskResponse.correctness_grade, "grade")
        exp = {
            'questionID': 1,
            'selectedOption': "A",
            'correctOption': "A",
            'correct': True,
            'correctOptionText': "text"
        }
        self.assertEqual(ret, [exp])
Example #2
0
    def test_has_questions(self):
        trquestion1 = {
            'questionID': 1,
            'correctOption': "A",
            'correctOptionText': "text"
        }
        question1 = {
            'questionID': 1,
            'selectedOption': "A",
        }
        taskResponse = Mock()
        taskResponse.graded_response = False
        taskResponse.response = json.dumps({
            'automatic_questions': [question1],
            'manual_questions': []
        })
        taskResponse.correctness_grade = None
        taskResponse.task = Mock()
        taskResponse.task.questions = json.dumps([trquestion1])
        self.models.TaskResponse.query.filter_by.return_value.first.return_value = taskResponse
        grader = grading.Grader()
        grader.calculate_correctness = Mock()
        grader.calculate_correctness.return_value = "grade"

        ret = grader.grade_automatic_questions(1)
        self.assertEqual(taskResponse.correctness_grade, "grade")
        exp = {
            'questionID': 1,
            'selectedOption': "A",
            'correctOption': "A",
            'correct': True,
            'correctOptionText': "text"
        }
        self.assertEqual(ret, [exp])
Example #3
0
def _get_test_conn():
    conn = Mock()
    conn.task = "test"
    conn.in_flight = 50
    conn.ready = 25
    conn.max_rdy_count = 50
    return conn
Example #4
0
def _get_test_conn():
    conn = Mock()
    conn.task = "test"
    conn.in_flight = 50
    conn.ready = 25
    conn.max_rdy_count = 50
    return conn
    def generate_mock_options():
        options = Mock()
        options.resmoke_args = "resmoke_args"
        options.run_multiple_jobs = "true"
        options.variant = "buildvariant"
        options.suite = "suite"
        options.task = "suite"

        return options
    def generate_mock_options():
        options = Mock()
        options.resmoke_args = "resmoke_args"
        options.run_multiple_jobs = "true"
        options.variant = "buildvariant"
        options.suite = "suite"
        options.task = "suite"
        options.use_large_distro = None

        return options
Example #7
0
    def generate_mock_options():
        options = Mock()
        options.resmoke_args = "resmoke_args"
        options.run_multiple_jobs = "true"
        options.variant = "buildvariant"
        options.suite = "suite"
        options.task = "suite"
        options.use_large_distro = None
        options.use_multiversion = False
        options.is_patch = True

        return options
    def generate_mock_options():
        options = Mock()
        options.resmoke_args = "resmoke_args"
        options.run_multiple_jobs = "true"
        options.variant = "buildvariant"
        options.suite = "suite"
        options.task = "suite"
        options.use_large_distro = None
        options.use_multiversion = False
        options.is_patch = True
        options.repeat_suites = 1

        return options
Example #9
0
 def test_ABCEFMPSUV(self):
     grader = grading.Grader()
     taskResponse = Mock()
     taskResponse.graded_response = False
     taskResponse.response = json.dumps({
         'automatic_questions': [],
         'manual_questions': []
         })
     taskResponse.correctness_grade = None
     taskResponse.task = Mock()
     taskResponse.task.questions = json.dumps([])
     self.models.TaskResponse.query.filter_by.return_value.first.return_value = taskResponse
     ret = grader.grade_automatic_questions(1)
     self.assertEqual(taskResponse.correctness_grade, 0)
     self.assertEqual(ret, [])
Example #10
0
 def test_ABCEFMPSUV(self):
     grader = grading.Grader()
     taskResponse = Mock()
     taskResponse.graded_response = False
     taskResponse.response = json.dumps({
         'automatic_questions': [],
         'manual_questions': []
     })
     taskResponse.correctness_grade = None
     taskResponse.task = Mock()
     taskResponse.task.questions = json.dumps([])
     self.models.TaskResponse.query.filter_by.return_value.first.return_value = taskResponse
     ret = grader.grade_automatic_questions(1)
     self.assertEqual(taskResponse.correctness_grade, 0)
     self.assertEqual(ret, [])
def get_submission(task=None, participation=None, sr=None, scored=True):
    task = task if task is not None else get_task()
    participation = participation if participation is not None \
        else get_participation()
    sr = sr if sr is not None else get_sr(scored=scored)

    submission = Mock()
    submission.timestamp = make_datetime(get_int(2 ** 11 + 2 ** 8, 2 ** 11))
    submission.tokened.return_value = False

    submission.get_result.return_value = sr
    submission.participation = participation
    submission.task = task

    submission.id = get_int()
    return submission
Example #12
0
def get_submission(task=None, participation=None, sr=None, scored=True):
    task = task if task is not None else get_task()
    participation = participation if participation is not None \
        else get_participation()
    sr = sr if sr is not None else get_sr(scored=scored)

    submission = Mock()
    submission.timestamp = make_datetime(get_int(2 ** 11 + 2 ** 8, 2 ** 11))
    submission.tokened.return_value = False

    submission.get_result.return_value = sr
    submission.participation = participation
    submission.task = task

    submission.id = get_int()
    return submission
def af_context_w_context():
    task_instance = Mock()
    task = Mock()
    task.template_fields = ["a", "b", "c"]
    task.a, task.b, task.c = 1, 1, 2

    task_instance.task = task
    task_instance.dag_id = "test_dag"
    task_instance.execution_date = "1970-01-01T00:00:00.000000+00:00"
    task_instance.task_id = "test_task"
    task_instance.try_number = 6
    task_instance.log_filepath = "mylog.log"

    context = {"task_instance": task_instance}
    return AirflowTaskContext(
        dag_id="test_dag",
        execution_date="1970-01-01T00:00:00.571846+00:00",
        task_id="test_task",
        try_number=6,
        context=context,
    )