def test_submitter_is_finished_num_queries(self): # Complete the first training example training_api.get_training_example(self.submission_uuid, RUBRIC, EXAMPLES) training_api.assess_training_example(self.submission_uuid, EXAMPLES[0]['options_selected']) # Check whether we've completed the requirements requirements = {'num_required': 2} with self.assertNumQueries(2): training_api.submitter_is_finished(self.submission_uuid, requirements)
def test_submitter_is_finished_num_queries(self): # Complete the first training example training_api.on_start(self.submission_uuid) training_api.get_training_example(self.submission_uuid, RUBRIC, EXAMPLES) training_api.assess_training_example(self.submission_uuid, EXAMPLES[0]['options_selected']) # Check whether we've completed the requirements requirements = {'num_required': 2} with self.assertNumQueries(2): training_api.submitter_is_finished(self.submission_uuid, requirements)
def _assert_workflow_status(self, submission_uuid, num_completed, num_required): """ Check that the training workflow is on the expected step. Args: submission_uuid (str): Submission UUID of the student being trained. num_completed (int): The expected number of examples assessed correctly. num_total (int): The required number of examples to assess. Returns: None Raises: AssertionError """ # Check the number of steps we've completed actual_num_completed = training_api.get_num_completed(submission_uuid) self.assertEqual(actual_num_completed, num_completed) # Check whether the assessment step is completed # (used by the workflow API) requirements = {'num_required': num_required} is_finished = training_api.submitter_is_finished( submission_uuid, requirements) self.assertEqual(is_finished, bool(num_completed >= num_required))
def _assert_workflow_status(self, submission_uuid, num_completed, num_required): """ Check that the training workflow is on the expected step. Args: submission_uuid (str): Submission UUID of the student being trained. num_completed (int): The expected number of examples assessed correctly. num_total (int): The required number of examples to assess. Returns: None Raises: AssertionError """ # Check the number of steps we've completed actual_num_completed = training_api.get_num_completed(submission_uuid) self.assertEqual(actual_num_completed, num_completed) # Check whether the assessment step is completed # (used by the workflow API) requirements = {'num_required': num_required} is_finished = training_api.submitter_is_finished(submission_uuid, requirements) self.assertEqual(is_finished, bool(num_completed >= num_required)) # Assessment is finished should always be true, # since we're not being assessed by others. self.assertTrue(training_api.assessment_is_finished(submission_uuid, requirements)) # At no point should we receive a score! self.assertIs(training_api.get_score(submission_uuid, requirements), None)
def test_is_finished_no_workflow(self): # Without creating a workflow, we should not be finished requirements = {'num_required': 1} self.assertFalse(training_api.submitter_is_finished(self.submission_uuid, requirements)) # But since we're not being assessed by others, the "assessment" should be finished. self.assertTrue(training_api.assessment_is_finished(self.submission_uuid, requirements))
def test_is_finished_no_workflow(self): # Without creating a workflow, we should not be finished requirements = {'num_required': 1} self.assertFalse( training_api.submitter_is_finished(self.submission_uuid, requirements)) # But since we're not being assessed by others, the "assessment" should be finished. self.assertTrue( training_api.assessment_is_finished(self.submission_uuid, requirements))
def test_submitter_is_finished_invalid_requirements(self, requirements): with self.assertRaises(StudentTrainingRequestError): training_api.submitter_is_finished(self.submission_uuid, requirements)
def test_is_finished_no_workflow(self): # Without creating a workflow, we should not be finished requirements = {'num_required': 1} self.assertFalse( training_api.submitter_is_finished(self.submission_uuid, requirements))
def test_submitter_is_finished_invalid_requirements(self, requirements): with self.assertRaises(StudentTrainingRequestError): training_api.submitter_is_finished(self.submission_uuid, requirements)
def test_is_finished_no_workflow(self): # Without creating a workflow, we should not be finished requirements = {'num_required': 1} self.assertFalse(training_api.submitter_is_finished(self.submission_uuid, requirements))