def test_source_notebooks(self):
        preprocessor = ExtractAssignmentInfo()
        path, resources = preprocessor.preprocess('', self.resources)

        assert 'source_notebooks' in resources
        assert 'problem_set_one.ipynb' in resources['source_notebooks']
        assert len(resources['source_notebooks']) == 1
    def test_extra_files(self):
        preprocessor = ExtractAssignmentInfo()
        path, resources = preprocessor.preprocess('', self.resources)

        assert 'extra_files' in resources
        assert 'base_path' in resources['extra_files']
        assert 'files' in resources['extra_files']
        assert resources['extra_files']['base_path'] == os.path.join(
            self.course_dir, 'source', self.assignment)
        assert len(resources['extra_files']['files']) == 1
        assert 'data/file.txt' in resources['extra_files']['files']
Example #3
0
 def test_tmp_folder_does_not_exist(self):
     path, resources = ExtractAssignmentInfo().preprocess(
         self.tmp_path, self.resources)
     path, resources = ExtractFeedback().preprocess(path, resources)
     del resources['tmp_folders']
     path, resources = CopyGroupFeedback().preprocess(path, resources)
     assert path in resources['tmp_folders']
Example #4
0
    def test_zip_feedback(self):
        path, resources = ExtractAssignmentInfo().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractFeedback().preprocess(path, resources)
        path, resources = CopyFeedback().preprocess(path, resources)
        path, resources = ZipFeedback().preprocess(path, resources)

        assert os.path.exists(path)
        assert os.path.isfile(os.path.join(path, 'multi_feedback.zip'))
    def test_rename(self):
        path, resources = Extract().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractAssignmentInfo().preprocess(path, resources)
        path, resources = CreateFolderStructure().preprocess(path, resources)
        path, resources = RenameSubmission().preprocess(path, resources)

        for uid, student in self.submitted:
            assert os.path.exists(os.path.join(path, uid))
 def test_tmp_folders(self):
     path, resources = ExtractAssignmentInfo().preprocess(
         self.tmp_path, self.resources)
     path, resources = Extract().preprocess(path, resources)
     path, resources = ExtractSingleSubmission().preprocess(path, resources)
     assert os.path.join(
         self.tmp_path,
         ExtractSingleSubmission().directory) in resources['tmp_folders']
    def test_rename(self):
        path, resources = Extract().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractAssignmentInfo().preprocess(path, resources)
        path, resources = CreateFolderStructure().preprocess(path, resources)
        path, resources = RenameNotebooks().preprocess(path, resources)

        for student in self.students:
            assert os.path.exists(os.path.join(path, student))
            for src_nb in resources['source_notebooks']:
                assert os.path.isfile(
                    os.path.join(path, student, self.assignment, src_nb))
 def test_copy_feedback(self):
     path, resources = ExtractAssignmentInfo().preprocess(
         self.tmp_path, self.resources)
     path, resources = ExtractFeedback().preprocess(path, resources)
     path, resources = CopyFeedback().preprocess(path, resources)
     assert os.path.exists(self.tmp_path)
     for student in self.students:
         assert os.path.exists(os.path.join(path, student))
         assert os.path.isfile(
             os.path.join(path, student, 'problem_set_one.html'))
     assert os.path.exists(os.path.join(path, 'student5'))
     assert not os.path.isfile(
         os.path.join(path, 'student5', 'problem_set_one.html'))
    def test_student2(self):
        '''
        Single notebook inside

        problem_set_one.ipynb
        '''
        path, resources = ExtractAssignmentInfo().preprocess(
            self.tmp_path, self.resources)
        path, resources = Extract().preprocess(path, resources)
        path, resources = ExtractSingleSubmission().preprocess(path, resources)
        assert os.path.exists(os.path.join(path, 'student2'))
        assert os.path.isfile(
            os.path.join(path, 'student2', 'problem_set_one.ipynb'))
Example #10
0
    def test_rename(self):
        path, resources = Extract().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractAssignmentInfo().preprocess(path, resources)
        path, resources = CreateFolderStructure().preprocess(path, resources)
        path, resources = AddExtraFiles().preprocess(path, resources)
        path, resources = RenameNotebooks().preprocess(path, resources)
        path, resources = RestructureSubmission().preprocess(path, resources)

        assert os.path.exists(path)
        assert os.path.isfile(
            os.path.join(self.tmp_path,
                         RestructureSubmission().directory, 'student2',
                         self.assignment, 'file.txt'))
    def test_other(self):
        path, resources = Extract().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractAssignmentInfo().preprocess(path, resources)
        path, resources = CreateFolderStructure().preprocess(path, resources)
        path, resources = RenameNotebooks().preprocess(path, resources)

        assert os.path.isfile(
            os.path.join(path, 'student3', self.assignment,
                         'problem_set_two.ipynb'))
        assert os.path.isfile(
            os.path.join(path, 'student4', self.assignment, 'ps2.ipynb'))
        assert not os.path.isfile(
            os.path.join(path, 'student5', self.assignment,
                         'problem_set_one.ipynb'))
    def test_extra_files(self):
        path, resources = Extract().preprocess(self.tmp_path, self.resources)
        path, resources = ExtractAssignmentInfo().preprocess(path, resources)
        path, resources = CreateFolderStructure().preprocess(path, resources)
        path, resources = AddExtraFiles().preprocess(path, resources)

        assert os.path.exists(path)

        for student in self.students:
            assert os.path.exists(os.path.join(path, student))
            assert os.path.exists(
                os.path.join(path, student, self.assignment, 'data'))
            assert os.path.isfile(
                os.path.join(path, student, self.assignment, 'data',
                             'file.txt'))
    def test_student1(self):
        '''
        Zipped folder with submission inside

        submission.zip
        └── some_folder
            └── problem_set_oneeeee.ipynb
        '''
        path, resources = ExtractAssignmentInfo().preprocess(
            self.tmp_path, self.resources)
        path, resources = Extract().preprocess(path, resources)
        path, resources = ExtractSingleSubmission().preprocess(path, resources)
        assert os.path.exists(os.path.join(path, 'student1'))
        assert os.path.isfile(
            os.path.join(path, 'student1', 'problem_set_oneeeee.ipynb'))
 def test_student3(self):
     '''
     Folder with a mix of zip and other files
     
     problem_set_one.ipynb
     problem_set_two.ipynb.zip
     '''
     path, resources = ExtractAssignmentInfo().preprocess(
         self.tmp_path, self.resources)
     path, resources = Extract().preprocess(path, resources)
     path, resources = ExtractSingleSubmission().preprocess(path, resources)
     assert os.path.exists(os.path.join(path, 'student3'))
     assert os.path.isfile(
         os.path.join(path, 'student3', 'problem_set_one.ipynb'))
     assert os.path.isfile(
         os.path.join(path, 'student3', 'problem_set_two.ipynb.zip'))
    def test_student5(self):
        '''
        Zipped folder with single file inside

        singlefile.zip
        └── a
            └── b
                ├── some_file.txt
                └── c
        '''
        path, resources = ExtractAssignmentInfo().preprocess(
            self.tmp_path, self.resources)
        path, resources = Extract().preprocess(path, resources)
        path, resources = ExtractSingleSubmission().preprocess(path, resources)
        assert os.path.exists(os.path.join(path, 'student5'))
        assert os.path.isfile(os.path.join(path, 'student5', 'some_file.txt'))
        assert not os.path.exists(os.path.join(path, 'student5', 'c'))
    def test_student4(self):
        '''
        Zipped folder with submission inside

        submission.zip
        └── nested_folder
            ├── problem_set_one_1.ipynb
            └── nested_subfolder
                └── ps2.ipynb
        '''
        path, resources = ExtractAssignmentInfo().preprocess(
            self.tmp_path, self.resources)
        path, resources = Extract().preprocess(path, resources)
        path, resources = ExtractSingleSubmission().preprocess(path, resources)
        assert os.path.exists(os.path.join(path, 'student4'))
        assert os.path.isfile(
            os.path.join(path, 'student4', 'problem_set_one_1.ipynb'))
        assert os.path.isdir(os.path.join(path, 'student4',
                                          'nested_subfolder'))
        assert os.path.isfile(
            os.path.join(path, 'student4', 'nested_subfolder', 'ps2.ipynb'))
Example #17
0
 def test_copy_feedback(self):
     path, resources = ExtractAssignmentInfo().preprocess(
         self.tmp_path, self.resources)
     path, resources = ExtractFeedback().preprocess(path, resources)
     path, resources = CopyGroupFeedback().preprocess(path, resources)
     assert os.path.exists(self.tmp_path)
     for uid, student in self.feedback:
         print(uid)
         assert os.path.exists(os.path.join(path, student))
         assert os.path.isfile(
             os.path.join(path, student, 'problem_set_one.html'))
     assert os.path.exists(
         os.path.join(path, 'Norbert_Notebookless_nnote2s_876543'))
     assert not os.path.isfile(
         os.path.join(path, 'Norbert_Notebookless_nnote2s_876543',
                      'problem_set_one.html'))
     assert os.path.exists(
         os.path.join(path, 'Susy_Nosubmission_snosub2s_6543210'))
     assert not os.path.isfile(
         os.path.join(path, 'Susy_Nosubmission_snosub2s_6543210',
                      'problem_set_one.html'))