def handle(self, args): static_dirs = get_static_dirs(self.settings) collect_dir = self.settings.get('static.collect_dir') print('Source directories: "{}"'.format('", "'.join(static_dirs))) print('Destination directory: "{}"\n'.format(collect_dir)) if args.clear: self.clear_folder_contents(collect_dir) total_files, num_files_copied, num_dirs_created = 0, 0, 0 for directory in static_dirs: total, num_copied, dirs_created = self.copy_files(directory, collect_dir, args.no_default_ignore) total_files += total num_files_copied += num_copied num_dirs_created += dirs_created # only print a newline if there was output during copying if num_dirs_created > 0 or num_files_copied > 0: print('') print('Number of files copied: {}'.format(num_files_copied)) print('Number of directories created: {}'.format(num_dirs_created)) print('Number of files un-modified: {}'.format(total_files - num_files_copied))
def test_static_view__success(self): request = testing.DummyRequest() request.matchdict['subpath'] = ('.gitkeep',) # a file that exists settings = { 'static.serve': True, 'static.dirs': 'pyramidcms:static' } settings['static.dirs'] = get_static_dirs(settings) request.registry.settings = settings # the file exists, should not raise a 404 static_view(request)
def test_static_view__notfound(self): request = testing.DummyRequest() request.matchdict['subpath'] = ('foo',) # a file that doesn't exist settings = { 'static.serve': True, 'static.dirs': 'pyramidcms:static' } settings['static.dirs'] = get_static_dirs(settings) request.registry.settings = settings # the file doesn't exist, should raise a 404 with self.assertRaises(HTTPNotFound): static_view(request)
def test_static_view__disabled(self): request = testing.DummyRequest() request.matchdict['subpath'] = ('.gitkeep',) # a file that exists settings = { 'static.serve': False, # must be False for this test 'static.dirs': 'pyramidcms:static' } settings['static.dirs'] = get_static_dirs(settings) request.registry.settings = settings # we can only really test for a 404 if static.serve is False. with self.assertRaises(HTTPNotFound): static_view(request)