~fmos/zim/features

« back to all changes in this revision

Viewing changes to tests/export.py

  • Committer: Fabian Moser
  • Date: 2011-01-26 20:33:29 UTC
  • mfrom: (297.1.43 pyzim-trunk)
  • Revision ID: e-mail+launchpad@fabianmoser.at-20110126203329-9qhtvpsf169hb18y
Merged main branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# Copyright 2009 Jaap Karssenberg <pardus@cpan.org>
4
4
 
5
 
from tests import TestCase, create_tmp_dir, get_test_notebook, get_test_data
 
5
from tests import TestCase, MockObject, create_tmp_dir, get_test_notebook, get_test_data
6
6
 
7
7
from subprocess import check_call
8
8
 
91
91
                TestExportFullOptions.runTest(self)
92
92
 
93
93
# TODO test export single page from command line
 
94
 
 
95
 
 
96
class TestExportDialog(TestCase):
 
97
 
 
98
        slowTest = True
 
99
 
 
100
        def runTest(self):
 
101
                from zim.gui.exportdialog import ExportDialog
 
102
 
 
103
                dir = Dir(create_tmp_dir('export_ExportDialog'))
 
104
 
 
105
                notebook = get_test_notebook()
 
106
                notebook.get_store(Path(':')).dir = Dir('/foo/bar') # fake source dir
 
107
                notebook.index.update()
 
108
 
 
109
                ui = MockObject()
 
110
                ui.notebook = notebook
 
111
                ui.mainwindow = None
 
112
 
 
113
                ## Test export all pages
 
114
                dialog = ExportDialog(ui)
 
115
                dialog.set_page(0)
 
116
 
 
117
                page = dialog.get_page()
 
118
                page.form['selection'] = 'all'
 
119
                dialog.next_page()
 
120
 
 
121
                page = dialog.get_page()
 
122
                page.form['format'] = 'HTML'
 
123
                page.form['template'] = 'Print'
 
124
                dialog.next_page()
 
125
 
 
126
                page = dialog.get_page()
 
127
                page.form['folder'] = dir
 
128
                page.form['index'] = 'INDEX_PAGE'
 
129
                dialog.assert_response_ok()
 
130
 
 
131
                file = dir.file('Test/foo.html')
 
132
                self.assertTrue(file.exists())
 
133
                text = file.read()
 
134
                self.assertTrue('<!-- Wiki content -->' in text, 'template used')
 
135
                self.assertTrue('<h1>Foo</h1>' in text)
 
136
 
 
137
 
 
138
                ## Test export single page
 
139
                dialog = ExportDialog(ui)
 
140
                dialog.set_page(0)
 
141
 
 
142
                page = dialog.get_page()
 
143
                page.form['selection'] = 'page'
 
144
                page.form['page'] = 'Test:foo'
 
145
                dialog.next_page()
 
146
 
 
147
                page = dialog.get_page()
 
148
                page.form['format'] = 'HTML'
 
149
                page.form['template'] = 'Print'
 
150
                dialog.next_page()
 
151
 
 
152
                page = dialog.get_page()
 
153
                page.form['file'] = dir.file('SINGLE_FILE_EXPORT.html').path
 
154
                dialog.assert_response_ok()
 
155
 
 
156
                file = dir.file('SINGLE_FILE_EXPORT.html')
 
157
                self.assertTrue(file.exists())
 
158
                text = file.read()
 
159
                self.assertTrue('<!-- Wiki content -->' in text, 'template used')
 
160
                self.assertTrue('<h1>Foo</h1>' in text)