def test_new_solution_override_old_solutions( self, exercise: Exercise, student_user: User, ): first_solution = conftest.create_solution(exercise, student_user) second_solution = conftest.create_solution(exercise, student_user) assert second_solution.state == self.created_state assert first_solution.refresh().state == self.old_solution_state next_unchecked = Solution.next_unchecked() assert next_unchecked is not None assert next_unchecked.id == second_solution.id next_unchecked = Solution.next_unchecked_of(exercise.id) assert next_unchecked is not None assert next_unchecked.id == second_solution.id assert next_unchecked.start_checking() assert next_unchecked.refresh().state == self.in_checking_state assert Solution.next_unchecked() is None assert Solution.next_unchecked_of(exercise.id) is None general_tasks.reset_solution_state_if_needed(second_solution.id) next_unchecked = Solution.next_unchecked() next_unchecked_by_id = Solution.next_unchecked_of(exercise.id) assert next_unchecked is not None and next_unchecked_by_id is not None assert next_unchecked.id == second_solution.id assert next_unchecked_by_id.id == second_solution.id third_solution = conftest.create_solution( exercise, student_user, code='123', ) fourth_solution = conftest.create_solution( exercise, student_user, code='1234', ) assert not Solution.is_duplicate( third_solution.hashed, student_user, exercise, already_hashed=True, ) assert Solution.is_duplicate( fourth_solution.hashed, student_user, exercise, already_hashed=True, )
def _is_uploaded_before( user: User, exercise: Exercise, file_hash: str, ) -> bool: return Solution.is_duplicate( file_hash, user, exercise, already_hashed=True, )
def _is_uploaded_before(user: User, file_hash: str) -> bool: return Solution.is_duplicate(file_hash, user, already_hashed=True)