def handle(self, *args, **options): users = User.objects.filter(is_staff=False) tasks = Task.objects.filter(category__name=options['category_name']) if Path(options['result_dir']).exists(): raise CommandError('result_dir already exists') jplag_check(users, tasks, options['min_similarity'], options['result_dir'])
def test_specific_users(self): """Verify that only the given users are checked.""" output = jplag_check( users=[self.alice], tasks=[self.task], min_similarity=100, ) self.assertNotIn(self.passed_solution_bob, output) self.assertNotIn(self.passed_solution_alice, output)
def test_jplag_check_without_resultdir(self): """JPlag check should return the right results also without result_dir.""" output = jplag_check( users=[self.alice, self.bob], tasks=[self.task], min_similarity=100, ) self.assertTrue(self.passed_solution_bob in output) self.assertTrue(self.passed_solution_alice in output)
def test_jplag_check_with_resultdir(self): """JPlag check should return the right results when given a result_dir.""" with TemporaryDirectory() as path: output = jplag_check(users=[self.alice, self.bob], tasks=[self.task], min_similarity=100, result_dir=Path(path).joinpath("jplag")) self.assertTrue(self.passed_solution_bob in output) self.assertTrue(self.passed_solution_alice in output)
def test_failed_solution_detection(self): """Validate that failed solutions are not taken into account.""" with TemporaryDirectory() as path: output = jplag_check(users=[self.alice, self.bob], tasks=[self.published_task1], min_similarity=1, result_dir=Path(path).joinpath("jplag")) self.assertNotIn(self.failed_solution_bob, output) self.assertNotIn(self.failed_solution_alice, output)
def test_jplag_check_with_resultdir(self): """JPlag check should return the right results when given a result_dir.""" with TemporaryDirectory() as path: output = jplag_check( users=[self.alice, self.bob], tasks=[self.task], min_similarity=100, result_dir=Path(path).joinpath("jplag") ) self.assertTrue(self.passed_solution_bob in output) self.assertTrue(self.passed_solution_alice in output)
def test_specific_tasks(self): """Verify that only the given tasks are checked.""" task_without_solutions = Task.objects.create( pubdate="2000-01-01 00:00Z", category_id=123456, title="Task without solutions", system_name="task-without-solutions") output = jplag_check( users=[self.alice, self.bob], tasks=[task_without_solutions], min_similarity=100, ) self.assertNotIn(self.passed_solution_bob, output) self.assertNotIn(self.passed_solution_alice, output) task_without_solutions.delete()
def handle(self, *args, **options): users = User.objects.filter(is_staff=False) tasks = Task.objects.filter(category__name=options["category_name"]) if Path(options["result_dir"]).exists(): raise CommandError("result_dir already exists") jplag_check(users, tasks, options["similarity"], options["result_dir"])