예제 #1
0
파일: tests.py 프로젝트: cytadela8/oioioi
    def test_handlers(self):
        submission = TestRunProgramSubmission.objects.get(pk=1)

        environ = create_environ()
        environ['job_id'] = 'job_id'
        environ['submission_id'] = submission.id
        environ['submission_kind'] = submission.kind
        environ['problem_instance_id'] = submission.problem_instance.id
        environ['problem_id'] = submission.problem.id
        environ['round_id'] = submission.problem_instance.round.id
        environ['contest_id'] = submission.problem_instance.id

        # Simulate successful compilation
        environ['compilation_result'] = 'OK'
        environ['compilation_message'] = ''

        environ = handlers.make_test(environ)

        self.assertIn('tests', environ)
        self.assertIn('test', environ['tests'])
        self.assertIn('in_file', environ['tests']['test'])

        # Simulate running tests
        FiletrackerStorage().save('output', ContentFile('o'))
        try:
            environ['test_results'] = {}
            environ['test_results']['test'] = {
                'result_cpode': 'OK',
                'result_string': 'OK',
                'time_used': 111,
                'out_file': '/output'
            }

            environ = handlers.grade_submission(environ)

            self.assertEqual(None, environ['score'])
            self.assertEqual('OK', environ['status'])

            environ = handlers.make_report(environ)
            self.assertIn('report_id', environ)
            report = TestRunReport.objects.get(
                                    submission_report=environ['report_id'])
            self.assertEqual(111, report.time_used)
            self.assertEqual('', report.comment)
            self.assertEqual('o', report.output_file.read())

            handlers.delete_output(environ)
        except Exception:
            get_client().delete_file('/output')
예제 #2
0
파일: tests.py 프로젝트: sio2project/oioioi
    def test_handlers(self):
        submission = TestRunProgramSubmission.objects.get(pk=1)

        environ = create_environ()
        environ['job_id'] = 'job_id'
        environ['submission_id'] = submission.id
        environ['submission_kind'] = submission.kind
        environ['problem_instance_id'] = submission.problem_instance.id
        environ['problem_id'] = submission.problem.id
        environ['round_id'] = submission.problem_instance.round.id
        environ['contest_id'] = submission.problem_instance.id

        # Simulate successful compilation
        environ['compilation_result'] = 'OK'
        environ['compilation_message'] = ''

        environ = handlers.make_test(environ)

        self.assertIn('tests', environ)
        self.assertIn('test', environ['tests'])
        self.assertIn('in_file', environ['tests']['test'])

        # Simulate running tests
        FiletrackerStorage().save('output', ContentFile('o'))
        try:
            environ['test_results'] = {}
            environ['test_results']['test'] = {
                'result_cpode': 'OK',
                'result_string': 'OK',
                'time_used': 111,
                'out_file': '/output'
            }

            environ = handlers.grade_submission(environ)

            self.assertEqual(None, environ['score'])
            self.assertEqual('OK', environ['status'])

            environ = handlers.make_report(environ)
            self.assertIn('report_id', environ)
            report = TestRunReport.objects.get(
                                    submission_report=environ['report_id'])
            self.assertEqual(111, report.time_used)
            self.assertEqual('', report.comment)
            self.assertEqual('o', report.output_file.read())

            handlers.delete_output(environ)
        except Exception:
            get_client().delete_file('/output')