コード例 #1
0
    def test_solve_solution_with_identical_code_not_identical_code(
            self,
            comment: models.Comment,
    ):
        _, another_solution = self._duplicate_solution_from_comment(
            comment=comment,
            first_solution_code=SOME_CODE * 2,
            second_solution_code=SOME_CODE,
        )

        assert len(tuple(another_solution.comments)) == 0
        tasks.solve_solution_with_identical_code(another_solution.id)
        assert len(tuple(another_solution.comments)) == 0
        assert another_solution.state == models.Solution.STATES.CREATED.name
コード例 #2
0
    def test_solve_solution_with_identical_code(self, comment: models.Comment):
        f_solution, s_solution = self._duplicate_solution_from_comment(
            comment=comment,
            first_solution_code=SOME_CODE,
            second_solution_code=SOME_CODE,
        )
        assert len(tuple(s_solution.comments)) == 0
        tasks.solve_solution_with_identical_code(s_solution.id)
        assert len(tuple(s_solution.comments)) == 1

        user_notifications = notifications.get(user=s_solution.solver)
        assert len(user_notifications) == 1
        solution_id = user_notifications[0].related_id
        assert s_solution.id == solution_id

        user_notifications = notifications.get(user=f_solution.solver)
        assert len(user_notifications) == 0
コード例 #3
0
    def test_solve_solution_with_identical_code(self, comment: models.Comment):
        f_solution, s_solution = self._duplicate_solution_from_comment(
            comment=comment,
            first_solution_code=SOME_CODE,
            second_solution_code=SOME_CODE,
        )
        assert len(tuple(s_solution.comments)) == 0
        tasks.solve_solution_with_identical_code(s_solution.id)
        assert len(tuple(s_solution.comments)) == 1

        user_notifications = notifications.get_notifications_for_user(
            for_user=s_solution.solver)
        assert len(user_notifications) == 1
        subject = user_notifications[0]['message_parameters']['exercise_name']
        assert s_solution.exercise.subject == subject

        user_notifications = notifications.get_notifications_for_user(
            for_user=f_solution.solver)
        assert len(user_notifications) == 0