def test_walktree_exits_when_it_encounters_permission_error(self): """ tests that walktree exits when it encounters a permission error while walking """ runlog = CommandFileUtils(self.dist_version, self.log_file, self.log_level) try: runlog.walktree('/etc', os.path.isfile, (), os.listdir, ()) except SystemExit as error: self.assertEqual(1, error.code, '%s exited with: %s' % ('walktree', str(error))) self.log('ERROR: Permission denied on: /etc/cups/ssl')
def test_walktree_with_no_directory_function_args(self): app_home_nested_file = os.path.join(self.app_home, 'app_name', 'file') os.makedirs(os.path.join(self.app_home, 'app_name')) with open(app_home_nested_file, 'w') as file: file.write('some text') runlog = CommandFileUtils(self.dist_version, self.log_file, self.log_level) runlog.walktree(self.app_home, d_callback=runlog.write_to_log) paths = ['/tmp/scripts_test/app_user/sites/app_name/source/app_name'] for p in paths: self.log('DEBUG: %s' % p)
def test_walktree_with_no_file_function_args(self): app_home_nested_file = os.path.join(self.test_dir, 'dir', 'file') os.makedirs(os.path.join(self.test_dir, 'dir')) with open(app_home_nested_file, 'w') as file: file.write('some text') runlog = CommandFileUtils(self.dist_version, self.log_file, self.log_level) runlog.walktree(self.test_dir, f_callback=runlog.write_to_log) paths = ['/tmp/scripts_test/dir/file'] for p in paths: self.log('DEBUG: %s' % p)
def test_walktree_with_no_file_function(self): app_home_nested_file = os.path.join(self.app_home, 'app_name', 'file') os.makedirs(os.path.join(self.app_home, 'app_name')) with open(app_home_nested_file, 'w') as file: file.write('some text') runlog = CommandFileUtils(self.dist_version, self.log_file, self.log_level) runlog.walktree(self.app_home, d_callback=runlog.write_to_log, d_args=('INFO', )) paths = ['/tmp/scripts_test/app_user/sites/app_name/source/app_name'] for p in paths: self.log('INFO: %s' % p) self.log('ERROR:', test=False, regex=True)
def test_walktree(self): app_home_nested_file = os.path.join(self.app_home, 'app_name', 'file') os.makedirs(os.path.join(self.app_home, 'app_name')) with open(app_home_nested_file, 'w') as file: file.write('some text') runlog = CommandFileUtils(self.dist_version, self.log_file, self.log_level) runlog.walktree(self.app_home, runlog.write_to_log, ('INFO', ), runlog.write_to_log, ('INFO', )) paths = ['/tmp/scripts_test/app_user/sites/app_name/source/app_name', '/tmp/scripts_test/app_user/sites/app_name/source/app_name/file'] for p in paths: self.log('INFO: %s' % p)