Beispiel #1
0
    def test_importing(self):
        test_info = self._get_base_test_info()
        test_info_2 = _updated_copy(test_info, {'metadata': '2,2,55'})

        results = [
            _updated_copy(test_info, {'metadata': '1a,1,2'}),
            _updated_copy(test_info, {
                'metadata': '1b,1,2',
                'verdict': 'Wrong answer'
            }),
            test_info_2,
        ]
        env = {'zeus_results': results, 'compilation_result': 'OK'}
        env = handlers.import_results(env)
        self.assertEqual(env['compilation_result'], 'OK')

        tests = env['tests']
        test_results = env['test_results']
        self.assertEqual(len(tests), 3)
        self.assertEqual(len(test_results), 3)
        self.assertAllIn(['1a', '1b', '2'], tests)

        self.assertDictContainsSubset(
            {
                'name': '1a',
                'kind': 'NORMAL',
                'group': '1',
                'max_score': 2,
                'exec_time_limit': 1000,
                'exec_memory_limit': 2**14,
                'zeus_metadata': '1a,1,2',
            },
            tests['1a'],
        )
        self.assertDictContainsSubset(
            {
                'result_code': 'WA',
                'result_string': '',
                'time_used': 100
            },
            test_results['1b'],
        )
        self.assertDictEqual(test_info_2,
                             test_results['2']['zeus_test_result'])

        env['zeus_results'].append(self._get_base_test_info(metadata='0,0,0'))
        env = handlers.import_results(env)
        self.assertEqual(len(tests), 4)
        self.assertEqual(len(test_results), 4)
        self.assertDictContainsSubset({
            'name': '0',
            'kind': 'EXAMPLE'
        }, env['tests']['0'])
Beispiel #2
0
    def test_make_zeus_testrun_report(self):
        report = _updated_copy(self._get_base_report(73579009, 'TESTRUN', ''),
                {'stdout_size': 1024, 'stdout': 'some out', 'stdout_uid': 918})
        env = {
            'zeus_results': [report],
            'score': None,
            'max_score': None,
            'status': 'OK',
            'zeus_metadata_decoder': 'oioioi.zeus.handlers.testrun_metadata',
            'submission_id': 1,
        }
        env = handlers.import_results(env, kind='TESTRUN')
        self.assertEqual(len(env['tests']), 1)
        self.assertEqual(len(env['test_results']), 1)
        env = handlers.make_zeus_testrun_report(env)
        submission_report = SubmissionReport.objects.get(id=env['report_id'])
        self.assertEqual(submission_report.kind, 'TESTRUN')
        tr_report = submission_report.testrunreport_set.get().zeustestrunreport
        self.assertEqual(tr_report.status, 'OK')
        self.assertEqual(tr_report.time_used, 100)
        self.assertEqual(tr_report.test_time_limit, 1000)
        self.assertEqual(tr_report.output_file.read(), 'some out')

        self.assertEqual(tr_report.full_out_size, 1024)
        self.assertEqual(tr_report.full_out_handle, '918')
Beispiel #3
0
    def test_compilation_failure(self):
        test_info = self._get_base_test_info()

        results = [
            _updated_copy(test_info, {'metadata': '0a,0,0'}),
            _updated_copy(test_info, {'metadata': '0b,0,0'})
        ]
        env = {'zeus_results': results, 'compilation_result': 'CE'}
        env = handlers.import_results(env, kind='INITIAL')
        self.assertNotIn('tests', env)
        self.assertNotIn('test_results', env)
Beispiel #4
0
    def test_compilation_failure(self):
        test_info = self._get_base_test_info()

        results = [
            _updated_copy(test_info, {'metadata': '0a,0,0'}),
            _updated_copy(test_info, {'metadata': '0b,0,0'})
        ]
        env = {'zeus_results': results, 'compilation_result': 'CE'}
        env = handlers.import_results(env, kind='INITIAL')
        self.assertNotIn('tests', env)
        self.assertNotIn('test_results', env)
    def test_importing(self):
        report = self._get_base_report(909941, 'NORMAL')
        other_report = self._get_base_report(9999, 'XXXX')
        report_2 = _updated_copy(report, {'metadata': '2,2,55'})
        results = [
            _updated_copy(report, {'metadata': '1a,1,2'}),
            _updated_copy(report, {'metadata': '1b,1,2', 'status': 'WA',
                'result_string': 'wa'}),
            report_2,
            other_report,
        ]
        env = {'zeus_results': results}
        env = handlers.import_results(env, kind='NORMAL')
        self.assertEqual(env['compilation_result'], 'OK')
        self.assertEqual(env['compilation_message'], '')

        tests = env['tests']
        test_results = env['test_results']
        self.assertEqual(len(tests), 3)
        self.assertEqual(len(test_results), 3)
        self.assertAllIn(['1a', '1b', '2'], tests)

        self.assertDictContainsSubset({'name': '1a', 'kind': 'NORMAL',
                    'group': '1', 'max_score': 2, 'exec_time_limit': 1000,
                    'exec_memory_limit': 2 ** 14, 'zeus_metadata': '1a,1,2'},
                tests['1a'])
        self.assertDictContainsSubset({'result_code': 'WA',
                'result_string': 'wa', 'time_used': 100}, test_results['1b'])
        self.assertDictEqual(report_2, test_results['2']['zeus_test_result'])

        env['zeus_results'].append(
                self._get_base_report(1917141, 'INITIAL', '0,0,0'))
        env = handlers.import_results(env, kind='INITIAL', map_to_kind='EGGY')
        self.assertEqual(len(tests), 4)
        self.assertEqual(len(test_results), 4)
        self.assertDictContainsSubset({'name': '0', 'kind': 'EGGY'},
                env['tests']['0'])
Beispiel #6
0
    def test_importing(self):
        report = self._get_base_report(909941, 'NORMAL')
        other_report = self._get_base_report(9999, 'XXXX')
        report_2 = _updated_copy(report, {'metadata': '2,2,55'})
        results = [
            _updated_copy(report, {'metadata': '1a,1,2'}),
            _updated_copy(report, {'metadata': '1b,1,2', 'status': 'WA',
                'result_string': 'wa'}),
            report_2,
            other_report,
        ]
        env = {'zeus_results': results}
        env = handlers.import_results(env, kind='NORMAL')
        self.assertEqual(env['compilation_result'], 'OK')
        self.assertEqual(env['compilation_message'], '')

        tests = env['tests']
        test_results = env['test_results']
        self.assertEqual(len(tests), 3)
        self.assertEqual(len(test_results), 3)
        self.assertAllIn(['1a', '1b', '2'], tests)

        self.assertDictContainsSubset({'name': '1a', 'kind': 'NORMAL',
                    'group': '1', 'max_score': 2, 'exec_time_limit': 1000,
                    'exec_memory_limit': 2 ** 14, 'zeus_metadata': '1a,1,2'},
                tests['1a'])
        self.assertDictContainsSubset({'result_code': 'WA',
                'result_string': 'wa', 'time_used': 100}, test_results['1b'])
        self.assertDictEqual(report_2, test_results['2']['zeus_test_result'])

        env['zeus_results'].append(
                self._get_base_report(1917141, 'INITIAL', '0,0,0'))
        env = handlers.import_results(env, kind='INITIAL', map_to_kind='EGGY')
        self.assertEqual(len(tests), 4)
        self.assertEqual(len(test_results), 4)
        self.assertDictContainsSubset({'name': '0', 'kind': 'EGGY'},
                env['tests']['0'])
    def test_compilation_failure(self):
        report = _updated_copy(
                self._get_base_report(1917141, 'INITIAL'),
                {'compilation_successful': False, 'compilation_message': 'xx'})

        results = [
            _updated_copy(report, {'metadata': '0a,0,0'}),
            _updated_copy(report, {'metadata': '0b,0,0'})
        ]
        env = {'zeus_results': results}
        env = handlers.import_results(env, kind='INITIAL')
        self.assertEqual(env['compilation_result'], 'CE')
        self.assertEqual(env['compilation_message'], 'xx')
        self.assertEqual(len(env['tests']), 2)
        self.assertEqual(len(env['test_results']), 2)
Beispiel #8
0
    def test_importing(self):
        test_info = self._get_base_test_info()
        test_info_2 = _updated_copy(test_info, {'metadata': '2,2,55'})

        results = [
            _updated_copy(test_info, {'metadata': '1a,1,2'}),
            _updated_copy(test_info, {'metadata': '1b,1,2',
                'verdict': 'Wrong answer'}),
            test_info_2
        ]
        env = {'zeus_results': results, 'compilation_result': 'OK'}
        env = handlers.import_results(env)
        self.assertEqual(env['compilation_result'], 'OK')

        tests = env['tests']
        test_results = env['test_results']
        self.assertEqual(len(tests), 3)
        self.assertEqual(len(test_results), 3)
        self.assertAllIn(['1a', '1b', '2'], tests)

        self.assertDictContainsSubset({'name': '1a', 'kind': 'NORMAL',
                    'group': '1', 'max_score': 2, 'exec_time_limit': 1000,
                    'exec_memory_limit': 2 ** 14, 'zeus_metadata': '1a,1,2'},
                tests['1a'])
        self.assertDictContainsSubset({'result_code': 'WA',
                'result_string': '', 'time_used': 100}, test_results['1b'])
        self.assertDictEqual(test_info_2,
                test_results['2']['zeus_test_result'])

        env['zeus_results'].append(
                self._get_base_test_info(metadata='0,0,0'))
        env = handlers.import_results(env)
        self.assertEqual(len(tests), 4)
        self.assertEqual(len(test_results), 4)
        self.assertDictContainsSubset({'name': '0', 'kind': 'EXAMPLE'},
                env['tests']['0'])
Beispiel #9
0
    def test_compilation_failure(self):
        report = _updated_copy(
                self._get_base_report(1917141, 'INITIAL'),
                {'compilation_successful': False, 'compilation_message': 'xx'})

        results = [
            _updated_copy(report, {'metadata': '0a,0,0'}),
            _updated_copy(report, {'metadata': '0b,0,0'})
        ]
        env = {'zeus_results': results}
        env = handlers.import_results(env, kind='INITIAL')
        self.assertEqual(env['compilation_result'], 'CE')
        self.assertEqual(env['compilation_message'], 'xx')
        self.assertNotIn('tests', env)
        self.assertNotIn('test_results', env)
    def test_make_zeus_testrun_report(self):
        report = _updated_copy(self._get_base_report(73579009, 'TESTRUN', ''),
                {'stdout_size': 1024, 'stdout': 'some out', 'stdout_uid': 918})
        env = {
            'zeus_results': [report],
            'score': None,
            'status': 'OK',
            'zeus_metadata_decoder': 'oioioi.zeus.handlers.testrun_metadata',
            'submission_id': 1,
        }
        env = handlers.import_results(env, kind='TESTRUN')
        self.assertEqual(len(env['tests']), 1)
        self.assertEqual(len(env['test_results']), 1)
        env = handlers.make_zeus_testrun_report(env)
        submission_report = SubmissionReport.objects.get(id=env['report_id'])
        self.assertEqual(submission_report.kind, 'TESTRUN')
        tr_report = submission_report.testrunreport_set.get().zeustestrunreport
        self.assertEqual(tr_report.status, 'OK')
        self.assertEqual(tr_report.time_used, 100)
        self.assertEqual(tr_report.test_time_limit, 1000)
        self.assertEqual(tr_report.output_file.read(), 'some out')

        self.assertEqual(tr_report.full_out_size, 1024)
        self.assertEqual(tr_report.full_out_handle, '918')