Example #1
0
    def test_get_grader_ready_data_raises_validation_error_when_language_not_in_supported_and_test_is_source(self):
        language = ProgrammingLanguageFactory(name='c_sharp')
        SourceCodeTestFactory._create(
            IncludedTask,
            task=self.task,
            language=language
        )

        with self.assertRaises(ValidationError):
            get_grader_ready_data(
                solution_id=self.solution.id,
                solution_model=Solution,
            )
Example #2
0
    def test_get_grader_ready_data_returns_problem_parameters_when_data_is_valid_and_test_is_source(self):
        language = ProgrammingLanguageFactory(name='java')
        SourceCodeTestFactory._create(
            IncludedTask,
            task=self.task,
            language=language
        )

        data = get_grader_ready_data(
            solution_id=self.solution.id,
            solution_model=Solution
        )

        self.assertIsInstance(data, dict)
Example #3
0
    def test_get_grader_ready_data_raises_validation_error_when_language_is_not_supported_and_test_is_not_source(self):
        language = ProgrammingLanguageFactory(name=faker.word())
        self.solution.code = None
        self.solution.file = SimpleUploadedFile('solution.jar', bytes(f'{faker.text()}'.encode('utf-8')))
        self.solution.save()
        BinaryFileTestFactory._create(
            IncludedTask,
            task=self.task,
            language=language
        )

        with self.assertRaises(ValidationError):
            get_grader_ready_data(
                solution_id=self.solution.id,
                solution_model=Solution,
            )
Example #4
0
    def test_get_grader_ready_data_return_problem_parameters_when_data_is_valid_and_test_is_not_source(self):
        language = ProgrammingLanguageFactory(name='java')
        self.solution.code = None
        self.solution.file = SimpleUploadedFile('solution.jar', bytes(f'{faker.text()}'.encode('utf-8')))
        self.solution.save()
        BinaryFileTestFactory._create(
            IncludedTask,
            task=self.task,
            language=language
        )

        data = get_grader_ready_data(
            solution_id=self.solution.id,
            solution_model=Solution
        )

        self.assertIsInstance(data, dict)
Example #5
0
    def test_problem_contains_extra_options_when_has_requirements_when_data_is_valid_and_test_is_source(self):

        language = ProgrammingLanguageFactory(name='java')
        test = SourceCodeTestFactory._create(
            IncludedTask,
            task=self.task,
            language=language
        )
        test.requirements = self.requirements
        test.save()

        data = get_grader_ready_data(
            solution_id=self.solution.id,
            solution_model=Solution
        )

        self.assertIsInstance(data, dict)
        self.assertFalse(data['extra_options'] == {})