Ejemplo n.º 1
0
 def test_files(self):
     output_path = 'job_dir'
     j = Job(user=self.user, status=Job.COMPLETED, output_path=output_path)
     j.save()
     
     dir_path = os.path.join(settings.FILES_BASE, output_path)
     if not os.path.exists(dir_path):
         os.makedirs(dir_path)
     output_path2 = 'job_dir/job_subdir'
     dir_path2 = os.path.join(settings.FILES_BASE, output_path2)
     if not os.path.exists(dir_path2):
         os.makedirs(dir_path2)
         
     file_names_to_contents = {
                             'file1': 'ksjhfewiu\n',
                             'filez2': 'faeowrfjieawmnc\n',
                             'file3': 'sdlkjfaeowijfiaowjef\n',
                             }
     file_names_to_contents2 = {
                             'job_subdir/fileA': 'aaaaahhhhhhh',
                             'job_subdir/fileB': 'baaaaaaaahhhhhh',
                             }
     from tao.tests import helper
     for file_name in file_names_to_contents.keys():
         helper.create_file(dir_path, file_name, file_names_to_contents)
     for file_name in file_names_to_contents2.keys():
         helper.create_file(dir_path, file_name, file_names_to_contents2)
         
     merged_file_names_to_contents = {}
     merged_file_names_to_contents.update(file_names_to_contents)
     merged_file_names_to_contents.update(file_names_to_contents2)
     self.assertEqual(sorted(merged_file_names_to_contents.keys()), sorted([job_file.file_name for job_file in j.files()]))