r36754 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36753‎ | r36754 | r36755 >
Date:16:33, 27 June 2008
Author:jojo
Status:old
Tags:
Comment:
adjust unittest. encoding fixes (only relevant for unittest)
Modified paths:
  • /trunk/extensions/Collection/pdf-server/pdfserver.py (modified) (history)
  • /trunk/extensions/Collection/pdf-server/tests.py (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/pdf-server/pdfserver.py
@@ -70,7 +70,7 @@
7171 def json_response(self, data):
7272 return {
7373 'content_type': 'application/json',
74 - 'content': simplejson.dumps(data),
 74+ 'content': simplejson.dumps(data).encode('utf-8'),
7575 }
7676
7777 def error_response(self, error):
@@ -127,9 +127,9 @@
128128 result = self.error_response('error executing command %r: %s' % (command, e))
129129
130130 if 'content_type' in result:
131 - print 'Content-Type: %s' % result['content_type']
 131+ print 'Content-Type: %s' % result['content_type'].encode('utf-8', 'ignore')
132132 if 'file_extension' in result:
133 - print 'Content-Disposition: inline;filename="collection.%s"' % result['file_extension']
 133+ print 'Content-Disposition: inline;filename="collection.%s"' % result['file_extension'].encode('utf-8', 'ignore')
134134 content = result.get('content', '')
135135 print 'Content-Length: %d' % len(content)
136136 print # end of headers
Index: trunk/extensions/Collection/pdf-server/tests.py
@@ -12,14 +12,14 @@
1313
1414 def setup_module(module):
1515 pdfserver.cache_dir = tempfile.mkdtemp()
16 - fd, pdfserver.mwpdf_logfile = tempfile.mkstemp()
 16+ fd, pdfserver.mwrender_logfile = tempfile.mkstemp()
1717 os.close(fd)
1818 fd, pdfserver.mwzip_logfile = tempfile.mkstemp()
1919 os.close(fd)
2020
2121 def teardown_module(module):
2222 shutil.rmtree(pdfserver.cache_dir)
23 - os.unlink(pdfserver.mwpdf_logfile)
 23+ os.unlink(pdfserver.mwrender_logfile)
2424 os.unlink(pdfserver.mwzip_logfile)
2525
2626 class FakeFieldStorage(object):
@@ -68,7 +68,7 @@
6969 assert 'no command' in result['error']
7070
7171 def test_missings_args():
72 - for cmd in ('pdf_generate', 'zip_post'):
 72+ for cmd in ('render', 'zip_post'):
7373 result = make_call({
7474 'command': cmd,
7575 })
@@ -76,14 +76,15 @@
7777
7878 def test_no_collection_id():
7979 result = make_call({
80 - 'command': 'pdf_status',
 80+ 'command': 'render_status',
8181 })
8282 assert 'collection ID' in result['error']
8383
8484 def test_pdf_generate():
8585 result = make_call({
86 - 'command': 'pdf_generate',
 86+ 'command': 'render',
8787 'base_url': 'http://en.wikipedia.org/w/',
 88+ 'writer': 'rl',
8889 'metabook': simplejson.dumps({
8990 'title': 'A Title',
9091 'subtitle': 'A Subtitle',
@@ -101,12 +102,12 @@
102103 while True:
103104 time.sleep(0.5)
104105 result = make_call({
105 - 'command': 'pdf_status',
 106+ 'command': 'render_status',
106107 'collection_id': collection_id,
107108 })
108109 assert result['collection_id'] == collection_id
109110 if result['state'] == 'progress':
110 - progress = result['progress']
 111+ progress = result['status']['progress']
111112 print 'progress:', progress
112113 assert progress >= last_progress
113114 last_progress = progress
@@ -117,7 +118,7 @@
118119 raise RuntimeError('unexpected state %r' % result['state'])
119120
120121 result = make_call({
121 - 'command': 'pdf_download',
 122+ 'command': 'download',
122123 'collection_id': collection_id,
123124 })
124125 assert result == 'pdf'

Status & tagging log