Ejemplo n.º 1
0
 def test_ensure_files(self):
     sf = create_submission_file()
     sub = create_validatable_submission(self.user,
                                         self.validated_assignment, sf)
     test_machine = self._register_executor()
     sub.assignment.test_machines.add(test_machine)
     job = server.fetch_job(self.config)
     self.assertNotEquals(None, job)
     self.assertTrue(job.ensure_files(['helloworld.c']))
Ejemplo n.º 2
0
 def test_grep(self):
     sf = create_submission_file()
     sub = create_validatable_submission(self.user,
                                         self.validated_assignment, sf)
     test_machine = self._register_executor()
     sub.assignment.test_machines.add(test_machine)
     job = server.fetch_job(self.config)
     self.assertNotEquals(None, job)
     self.assertListEqual(job.grep("World"), ['helloworld.c'])
     self.assertListEqual(job.grep("foobar"), [])
Ejemplo n.º 3
0
 def test_fetch_job_renaming(self):
     test_machine = self._register_executor()
     self.validated_assignment.test_machines.add(test_machine)
     with open(rootdir + "submfiles/validation/1000fff/helloworld.c",
               'rb') as f:
         self.c.post(
             '/assignments/%s/new/' % self.validated_assignment.pk, {
                 'notes': 'This is a test submission.',
                 'authors': str(self.user.pk),
                 'attachment': f
             })
     job = server.fetch_job(self.config)
     self.assertIn('helloworld.c', os.listdir(job.working_dir))
Ejemplo n.º 4
0
    def test_send_result(self):
        sf = create_submission_file()
        sub = create_validatable_submission(self.user,
                                            self.validated_assignment, sf)
        test_machine = self._register_executor()
        sub.assignment.test_machines.add(test_machine)

        job = server.fetch_job(self.config)
        self.assertNotEquals(None, job)

        msg = uccrap + "Message from validation script."

        job.send_pass_result(info_student=msg)

        db_entries = SubmissionTestResult.objects.filter(
            kind=SubmissionTestResult.VALIDITY_TEST)

        self.assertEqual(db_entries[0].result, msg)
Ejemplo n.º 5
0
 def test_job_attributes(self):
     sf = create_submission_file()
     sub = create_validatable_submission(self.user,
                                         self.validated_assignment, sf)
     test_machine = self._register_executor()
     sub.assignment.test_machines.add(test_machine)
     job = server.fetch_job(self.config)
     self.assertNotEquals(None, job)
     self.assertEquals(job.timeout,
                       self.validated_assignment.attachment_test_timeout)
     self.assertEquals(job.sub_id, str(sub.pk))
     self.assertEquals(job.file_id, str(sf.pk))
     self.assertEquals(job.submitter_name, sub.submitter.get_full_name())
     self.assertEquals(job.submitter_student_id,
                       str(sub.submitter.profile.student_id))
     self.assertEquals(job.submitter_studyprogram,
                       str(sub.submitter.profile.study_program))
     self.assertEquals(job.course, str(self.course))
     self.assertEquals(job.assignment, str(self.validated_assignment))
Ejemplo n.º 6
0
 def test_wrong_compile_call(self):
     sf = create_submission_file()
     sub = create_validatable_submission(self.user,
                                         self.validated_assignment, sf)
     test_machine = self._register_executor()
     sub.assignment.test_machines.add(test_machine)
     job = server.fetch_job(self.config)
     # Missing output
     self.assertRaises(exceptions.ValidatorBrokenException,
                       job.run_compiler,
                       inputs=['input.c'])
     # Missing input
     self.assertRaises(exceptions.ValidatorBrokenException,
                       job.run_compiler,
                       output='output')
     # Wrong file, determined by compiler
     self.assertRaises(exceptions.WrongExitStatusException,
                       job.run_compiler,
                       inputs=['foo.c'],
                       output='output')
Ejemplo n.º 7
0
 def test_cleanup(self):
     '''
     If configured, then the executor should remove all temporary
     files after finishing.
     '''
     for do_cleanup in [False, True]:
         sf = create_submission_file()
         sub = create_validatable_submission(self.user,
                                             self.validated_assignment, sf)
         test_machine = self._register_executor()
         sub.assignment.test_machines.add(test_machine)
         job = server.fetch_job(self.config)
         self.assertNotEquals(None, job)
         working_dir = job.working_dir
         job._config.set("Execution", "cleanup", str(do_cleanup))
         job._run_validate()
         if do_cleanup:
             with self.assertRaises(FileNotFoundError):
                 os.listdir(working_dir)
         else:
             self.assertNotEqual(os.listdir(working_dir), [])