def _export_to_pdf(self, action): """ Menu activation handler for PDF export. Calls the `Export` module from `export.py` to handle the actual file manipulation. """ del action doc = self.window.get_active_document() if not doc: print('[Export to PDF] No document.') return Export.export_pdf(doc)
def test_export_to_pdf(self, mock_call, mock_writer, mock_os, _): mock_writer.write_temp_file.return_value = self.path mock_os.path.splitext.return_value = ['base1', 'base2'] call_args = 'lowriter --headless --convert-to pdf --outdir'.split( ' ') + ['/some/path', 'base1.html'] Export.export_pdf(self.document) mock_writer.write_temp_file.assert_called_once_with(self.document) mock_writer.write_exported_html_file.assert_called_once_with( ['markdown', self.path], 'base1.html') mock_call.assert_called_once_with(call_args) self.assertSequenceEqual( mock_os.remove.call_args_list, [mock.call(self.path), mock.call('base1.html')])