Ejemplo n.º 1
0
 def test_makelog(self):
     with no_stderrout():
         paths = self.make_paths()
         start_makelog(paths)
         write_to_makelog(paths, 'Hello, World!')
         end_makelog(paths)
         self.check_makelog(paths)
Ejemplo n.º 2
0
 def test_log_output_depth_one(self):
     with no_stderrout():
         paths = self.make_paths(
             output_path='test/raw/log_outputs/dir_depth')
         log_files_in_output(paths, depth=1)
         self.assertIn('depth_1.txt', read_file(paths['output_statslog']))
         self.assertIn('depth_2.txt', read_file(paths['output_statslog']))
Ejemplo n.º 3
0
    def setup_directories(self):
        with no_stderrout():
            remove_dir(['test/external/', 'test/input/'])
            clear_dir(['test/output/', 'test/log/'])

        if not os.path.isdir('test/raw/move_sources/dir/'):
            os.makedirs('test/raw/move_sources/dir/')     
Ejemplo n.º 4
0
 def test_makelog_character(self):
     with no_stderrout():
         paths = self.make_paths(makelog_path='test/log/make_╬▓.log')
         start_makelog(paths)
         write_to_makelog(paths, 'Hello, World! ╬▓')
         end_makelog(paths)
         self.check_makelog(paths)
Ejemplo n.º 5
0
 def make_paths(self, makelog_path = 'test/log/make.log'):
     paths = {'makelog': makelog_path}
     
     with no_stderrout():
         start_makelog(paths)
         
     return(paths)
Ejemplo n.º 6
0
 def test_error_bad_paths(self):
     with self.assertRaises(Exception):
         with no_stderrout():
             paths = {}
             start_makelog(paths)
             write_to_makelog(paths, 'Hello, World!')
             end_makelog(paths)
Ejemplo n.º 7
0
    def test_zip_to_not_exist_file(self):
        # Zip directory
        with no_stderrout():
            zip_dir('test/output/', 'test/output/zipped.zip')

        # Check zip
        self.assertTrue(os.path.isfile('test/output/zipped.zip'))
Ejemplo n.º 8
0
 def test_program(self):        
     with no_stderrout():
         paths = self.make_paths()
         program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext)
         run_function(paths, program = program_name)
         
     self.check_output(paths)
Ejemplo n.º 9
0
 def test_program_space(self):        
     with no_stderrout():
         paths = self.make_paths(makelog_path = 'test/log/make space.log')
         program_name = 'test/raw/run_program/%s_script space.%s' % (self.app, self.ext)
         run_function(paths, program = program_name)
         
     self.check_output(paths)
Ejemplo n.º 10
0
 def test_log_output_no_log(self):
     with no_stderrout():
         paths = self.make_paths(output_path='test/raw/log_outputs/dir',
                                 output_statslog='')
         log_files_in_output(paths)
         self.check_makelog(paths)
         self.assertFalse(os.path.isfile(paths['output_statslog']))
Ejemplo n.º 11
0
 def test_makelog_space(self):
     with no_stderrout():
         paths = self.make_paths(makelog_path='test/log/make space.log')
         start_makelog(paths)
         write_to_makelog(paths, 'Hello, World!')
         end_makelog(paths)
         self.check_makelog(paths)
Ejemplo n.º 12
0
 def test_log_space(self):      
     with no_stderrout():
         paths = self.make_paths()
         program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext)
         run_function(paths, program = program_name, log = 'test/output/log space.log')
         
     self.check_output(paths)
     self.assertIn('Test script complete', read_file('test/output/log space.log'))
Ejemplo n.º 13
0
    def test_program_handout(self):
        with no_stderrout():
            paths = self.make_paths()
            program_name = 'test/raw/run_program/%s_file_handout.%s' % (
                self.app, self.ext)
            run_function(paths, program=program_name, doctype='handout')

        self.check_output(paths, '%s_file_handout.pdf' % self.app)
Ejemplo n.º 14
0
 def test_log_output_depth_one(self):
     with no_stderrout():
         paths = self.make_paths()
         inputs = link_inputs(paths,
                              ['test/raw/log_sources/move_depth.txt'])
         write_source_logs(paths, inputs, depth=1)
         self.assertIn('depth_1.txt', read_file(paths['source_statslog']))
         self.assertIn('depth_2.txt', read_file(paths['source_statslog']))
Ejemplo n.º 15
0
 def test_error_bad_arg(self):      
     try:
         with no_stderrout():
             paths = self.make_paths()
             program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext)
             run_function(paths, program = program_name, arg = [])    
     except Exception as e:
         self.assertRaises(Exception, e)
Ejemplo n.º 16
0
 def test_log_output_character(self):
     with no_stderrout():
         paths = self.make_paths()
         inputs = link_inputs(paths, ['test/raw/log_sources/move_╬▓.txt'])
         write_source_logs(paths, inputs)
         self.check_makelog(paths)
         self.assertIn('dir_╬▓', read_file(paths['source_maplog']))
         self.assertIn('file_╬▓.txt', read_file(paths['source_statslog']))
Ejemplo n.º 17
0
 def test_error_program_wrong_extension(self):      
     try:
         with no_stderrout():
             paths = self.make_paths()
             program_name = 'test/raw/run_program/wrong_extension.txt'
             run_function(paths, program = program_name)           
     except Exception as e:
         self.assertRaises(Exception, e)
Ejemplo n.º 18
0
 def test_error_bad_path(self):
     with no_stderrout():
         try:
             paths = {}
             log_files_in_output(paths)
             self.check_logs(paths)
         except Exception as e:
             self.assertRaises(Exception, e)
Ejemplo n.º 19
0
    def test_program_character(self):
        with no_stderrout():
            paths = self.make_paths(makelog_path='test/log/make_╬▓.log')
            program_name = 'test/raw/run_program/%s_file_╬▓.%s' % (self.app,
                                                                   self.ext)
            run_function(paths, program=program_name)

        self.check_output(paths, '%s_file_╬▓.pdf' % self.app)
Ejemplo n.º 20
0
 def test_log_output_space(self):
     with no_stderrout():
         paths = self.make_paths(
             output_path='test/raw/log_outputs/dir space')
         log_files_in_output(paths)
         self.check_makelog(paths)
         self.assertIn('file space.txt',
                       read_file(paths['output_statslog']))
Ejemplo n.º 21
0
 def test_error_bad_path(self):
     with no_stderrout():
         try:
             paths = {}
             inputs = link_inputs(paths,
                                  ['test/raw/log_sources/move space.txt'])
             write_source_logs(paths, inputs)
         except Exception as e:
             self.assertRaises(Exception, e)
Ejemplo n.º 22
0
 def test_error_program_missing(self):
     try:
         with no_stderrout():
             paths = self.make_paths()
             program_name = 'test/raw/run_program/%s_file_missing.%s' % (
                 self.app, self.ext)
             run_function(paths, program=program_name)
     except Exception as e:
         self.assertRaises(Exception, e)
Ejemplo n.º 23
0
    def test_no_log(self):        
        with no_stderrout():
            paths = self.make_paths(makelog_path = '')
            program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext)
            run_function(paths, program = program_name, log = '')

        self.assertFalse(os.path.isfile(paths['makelog']))
        self.assertFalse(os.path.isfile('test/output/log.log'))
        self.assertTrue(os.path.isfile('test/output/output.csv'))
Ejemplo n.º 24
0
    def make_paths(self,
                   makelog_path='test/log/make.log',
                   output_dir='test/output'):
        paths = {'makelog': makelog_path, 'output_dir': output_dir}

        with no_stderrout():
            start_makelog(paths)

        return (paths)
Ejemplo n.º 25
0
 def test_log_output_local_string(self):
     with no_stderrout():
         paths = self.make_paths(
             output_path='test/raw/log_outputs/dir',
             output_local_path='test/raw/log_outputs/dir_local')
         log_files_in_output(paths)
         self.check_logs(paths)
         self.assertIn('file_local.txt',
                       read_file(paths['output_statslog']))
Ejemplo n.º 26
0
 def test_program_arg(self):      
     with no_stderrout():
         paths = self.make_paths()
         program_name = 'test/raw/run_program/%s_script_arg.%s' % (self.app, self.ext)
         run_function(paths, program = program_name, args = self.arg)
     
     self.check_output(paths)
     output = read_file('test/output/output.csv')
     self.assertTrue(re.search('arg', output))
Ejemplo n.º 27
0
 def test_log_output_no_log(self):
     with no_stderrout():
         paths = self.make_paths(source_maplog_path='',
                                 source_statslog_path='')
         inputs = link_inputs(paths,
                              ['test/raw/log_sources/move space.txt'])
         write_source_logs(paths, inputs)
         self.check_makelog(paths)
         self.assertFalse(os.path.isfile(paths['source_maplog']))
         self.assertFalse(os.path.isfile(paths['source_statslog']))
Ejemplo n.º 28
0
    def test_zip_to_exist_file(self):
        create_file('test/output/zipped.zip')

        with no_stderrout():
            zip_dir('test/output/', 'test/output/zipped.zip')

        # Check zip
        self.assertTrue(os.path.isfile('test/output/zipped.zip'))
        unzip('test/output/unzip.zip', 'test/output/unzipped/')
        self.assertTrue(os.path.isfile('test/output/unzipped/file.txt'))
Ejemplo n.º 29
0
    def test_program_executable(self):
        with no_stderrout():
            paths = self.make_paths()
            program_name = 'test/raw/run_program/%s_file.%s' % (self.app,
                                                                self.ext)
            run_function(paths,
                         program=program_name,
                         executable=self.executable)

        self.check_output(paths)
Ejemplo n.º 30
0
    def test_error_corrupt_paths(self):        
        with self.assertRaises(Exception):
            with no_stderrout():
                paths = {'makelog': 'test/log/make.log', 
                         'input_dir': 'test/input/', 
                         'external_dir': 'test/external/',
                         'bad_key': []}

                self.move_function(paths, ['test/raw/move_sources/move_file.txt'])
                self.check_move(paths)