def document_invalid_files(document_data, audio_file): args_data = get_content_node_args(document_data) contentnode_kwargs = get_content_node_kwargs(document_data) contentnode_kwargs['files'] = [] # clear files becuse added one above document = DocumentNode(*args_data, **contentnode_kwargs) document.add_file(audio_file) return document
def document(document_file, document_data, channel): args_data = get_content_node_args(document_data) contentnode_kwargs = get_content_node_kwargs(document_data) document = DocumentNode(*args_data, **contentnode_kwargs) document.add_file(document_file) channel.add_child(document) document_data['files'].append( document_file) # save it so we can compare later return document
def test_invalid_epub_fails(self, invalid_epub_file): node = DocumentNode('doc-src-id', "Document", licenses.PUBLIC_DOMAIN, thumbnail=None) node.add_file(invalid_epub_file) config.THUMBNAILS = True filenames = node.process_files() # assert filenames == [None], 'expected one None filename (the broken epub)' # TODO: implement epub deep validation assert len(config.FAILED_FILES) == 1, 'expected one failed file'
def test_generate_thumbnail_from_epub(self, epub_file): node = DocumentNode('doc-src-id', "Document", licenses.PUBLIC_DOMAIN, thumbnail=None) node.add_file(epub_file) config.THUMBNAILS = True filenames = node.process_files() assert len(filenames) == 2, 'expected two filenames' self.check_has_thumbnail(node)
def test_invalid_htmlzip_fails(self, html_invalid_file): node = DocumentNode('doc-src-id', "Document", licenses.PUBLIC_DOMAIN, thumbnail=None) node.add_file(html_invalid_file) config.THUMBNAILS = True filenames = node.process_files() assert filenames == [None ], 'expected one None filename (the broken html)' assert len(config.FAILED_FILES) == 1, 'expected one failed file'
def test_non_existent_epub_fails(self): node = DocumentNode('doc-src-id', "Document", licenses.PUBLIC_DOMAIN, thumbnail=None) non_existent_path = 'does/not/exist.epub' document_file = DocumentFile(non_existent_path, language='en') node.add_file(document_file) config.THUMBNAILS = True filenames = node.process_files() assert filenames == [None], 'expected one None (the non existent epub)' assert len(config.FAILED_FILES) == 1, 'expected one failed file'