Пример #1
0
    def test_get_user_tests_operations_mixed(self):
        """Test with many different user_test statuses."""
        expected_operations = set()

        # A user_test for a different contest.
        self.add_user_test()

        # A user_test that failed compilation.
        self.add_user_test_with_results(False)

        # A user_test without results.
        user_test = self.add_user_test(self.tasks[0], self.participation)
        self.session.flush()
        expected_operations.update(set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset)))

        # A user_test with results to be compiled.
        user_test, results = self.add_user_test_with_results()
        self.session.flush()
        expected_operations.update(set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset)))

        # A user_test with results to be evaluated.
        user_test, results = self.add_user_test_with_results(True)
        self.session.flush()
        expected_operations.update(set(
            self.user_test_evaluation_operation(result)
            for result in results if self.to_judge(result.dataset)))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #2
0
    def test_get_user_tests_operations_no_operations(self):
        """Test for user_tests without operations to do."""
        # A user_test for a different contest.
        self.add_user_test()

        # A user_test that failed compilation.
        self.add_user_test_with_results(False)

        # A user_test completely evaluated.
        user_test, results = self.add_user_test_with_results(True)
        for result in results:
            result.set_evaluation_outcome()

        # A user_test reaching maximum tries for compilation
        user_test, results = self.add_user_test_with_results()
        for result in results:
            result.compilation_tries = 25

        # A user_test reaching maximum tries for evaluation
        user_test, results = self.add_user_test_with_results(True)
        for result in results:
            result.evaluation_tries = 25

        self.session.flush()
        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            set())
Пример #3
0
    def test_get_user_tests_operations_no_operations(self):
        """Test for user_tests without operations to do."""
        # A user_test for a different contest.
        self.add_user_test()

        # A user_test that failed compilation.
        self.add_user_test_with_results(False)

        # A user_test completely evaluated.
        user_test, results = self.add_user_test_with_results(True)
        for result in results:
            result.set_evaluation_outcome()

        # A user_test reaching maximum tries for compilation
        user_test, results = self.add_user_test_with_results()
        for result in results:
            result.compilation_tries = 25

        # A user_test reaching maximum tries for evaluation
        user_test, results = self.add_user_test_with_results(True)
        for result in results:
            result.evaluation_tries = 25

        self.session.flush()
        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            set())
Пример #4
0
    def test_get_user_tests_operations_mixed(self):
        """Test with many different user_test statuses."""
        expected_operations = set()

        # A user_test for a different contest.
        self.add_user_test()

        # A user_test that failed compilation.
        self.add_user_test_with_results(False)

        # A user_test without results.
        user_test = self.add_user_test(self.tasks[0], self.participation)
        self.session.flush()
        expected_operations.update(set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset)))

        # A user_test with results to be compiled.
        user_test, results = self.add_user_test_with_results()
        self.session.flush()
        expected_operations.update(set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset)))

        # A user_test with results to be evaluated.
        user_test, results = self.add_user_test_with_results(True)
        self.session.flush()
        expected_operations.update(set(
            self.user_test_evaluation_operation(result)
            for result in results if self.to_judge(result.dataset)))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #5
0
    def test_get_user_tests_operations_to_evaluate(self):
        """Test for a compiled user_test."""
        user_test, results = self.add_user_test_with_results(True)
        self.session.flush()

        expected_operations = set(
            self.user_test_evaluation_operation(result)
            for result in results if self.to_judge(result.dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #6
0
    def test_get_user_tests_operations_with_results(self):
        """Test for a user_test with user_test results."""
        user_test, results = self.add_user_test_with_results()
        self.session.flush()

        expected_operations = set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #7
0
    def test_get_user_tests_operations_to_evaluate(self):
        """Test for a compiled user_test."""
        user_test, results = self.add_user_test_with_results(True)
        self.session.flush()

        expected_operations = set(
            self.user_test_evaluation_operation(result) for result in results
            if self.to_judge(result.dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #8
0
    def test_get_user_tests_operations_with_results(self):
        """Test for a user_test with user_test results."""
        user_test, results = self.add_user_test_with_results()
        self.session.flush()

        expected_operations = set(
            self.user_test_compilation_operation(user_test, dataset)
            for dataset in user_test.task.datasets if self.to_judge(dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #9
0
    def test_get_user_tests_operations_with_results_second_try(self):
        """Test for a user_test with user_test results."""
        user_test, results = self.add_user_test_with_results()
        for result in results:
            result.compilation_tries = 1
        self.session.flush()

        expected_operations = set(
            self.user_test_compilation_operation(
                user_test, result.dataset, result)
            for result in results if self.to_judge(result.dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)
Пример #10
0
    def test_get_user_tests_operations_with_results_second_try(self):
        """Test for a user_test with user_test results."""
        user_test, results = self.add_user_test_with_results()
        for result in results:
            result.compilation_tries = 1
        self.session.flush()

        expected_operations = set(
            self.user_test_compilation_operation(user_test, result.dataset,
                                                 result) for result in results
            if self.to_judge(result.dataset))

        self.assertEqual(
            set(get_user_tests_operations(self.session, self.contest.id)),
            expected_operations)