2013-03-17 05:08:06 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-11-17 14:53:42 +00:00
|
|
|
# Test output files
|
2014-11-14 12:29:36 +00:00
|
|
|
|
2013-03-17 05:08:06 +00:00
|
|
|
import unittest
|
|
|
|
import os
|
|
|
|
|
2014-11-14 12:29:36 +00:00
|
|
|
from test import Common
|
2013-03-17 05:08:06 +00:00
|
|
|
|
2014-11-17 14:53:42 +00:00
|
|
|
class test_output(Common, unittest.TestCase):
|
2014-11-14 12:29:36 +00:00
|
|
|
def run_test_case(self, input_file, expected_output_files, args=[]):
|
2014-11-17 14:53:42 +00:00
|
|
|
if self.GENERATING_MODE:
|
|
|
|
self.skipTest("Skipping test_output test cases in generating mode")
|
2014-11-14 12:29:36 +00:00
|
|
|
args = list(args)
|
2014-11-17 14:53:42 +00:00
|
|
|
args.insert(0, os.path.join(self.TEST_DIR, 'test_output', input_file))
|
2014-11-16 14:52:40 +00:00
|
|
|
self.assertItemsEqual(self.run_pdf2htmlEX(args)['output_files'], expected_output_files)
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_default_name_single_page_pdf(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('1-page.pdf', ['1-page.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_default_name_multiple_page_pdf(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['2-pages.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_specify_name_single_page_pdf(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('1-page.pdf', ['foo.html'], ['foo.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_specify_name_multiple_page_pdf(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['foo.html'], ['foo.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_default_name_single_page(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('1-page.pdf', ['1-page.html', '1-page1.page'], ['--split-pages', 1])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_default_name_multiple_pages(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', '3-pages1.page', '3-pages2.page', '3-pages3.page'], ['--split-pages', 1])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_single_page(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('1-page.pdf', ['1-page.html', 'foo1.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_multiple_pages(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'foo1.xyz', 'foo2.xyz', 'foo3.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_formatter_multiple_pages(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o.xyz', 'fo2o.xyz', 'fo3o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_formatter_with_padded_zeros_multiple_pages(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo001o.xyz', 'fo002o.xyz', 'fo003o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%03do.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_first_formatter_gets_taken(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f1o%do.xyz', 'f2o%do.xyz', 'f3o%do.xyz'], ['--split-pages', 1, '--page-filename', 'f%do%do.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_s(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%soo1.xyz', 'f%soo2.xyz', 'f%soo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%soo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_p(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%poo1.xyz', 'f%poo2.xyz', 'f%poo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%poo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_n(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%noo1.xyz', 'f%noo2.xyz', 'f%noo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%noo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%oo1.xyz', 'f%%oo2.xyz', 'f%%oo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%%oo.xyz'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
2013-03-18 06:39:02 +00:00
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%o1o.xyz', 'f%%o2o.xyz', 'f%%o3o.xyz'], ['--split-pages', 1, '--page-filename', 'f%%o%do.xyz'])
|
2013-03-18 06:39:02 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o%%.xyz', 'fo2o%%.xyz', 'fo3o%%.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do%%.xyz'])
|
2013-03-18 06:39:02 +00:00
|
|
|
|
2013-03-18 04:31:43 +00:00
|
|
|
def test_generate_split_pages_specify_name_only_formatter_starts_part_way_through_invalid_formatter(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%021oo.xyz', 'f%022oo.xyz', 'f%023oo.xyz'], ['--split-pages', 1, '--page-filename', 'f%02%doo.xyz'])
|
2013-03-18 04:31:43 +00:00
|
|
|
|
|
|
|
def test_generate_split_pages_specify_output_filename_no_formatter_no_extension(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('1-page.pdf', ['1-page.html', 'foo1'], ['--split-pages', 1, '--page-filename', 'foo'])
|
2013-03-18 04:31:43 +00:00
|
|
|
|
2013-03-17 05:08:06 +00:00
|
|
|
def test_generate_single_html_name_specified_format_characters_percent_d(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['foo%d.html'], ['foo%d.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_name_specified_format_characters_percent_p(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['foo%p.html'], ['foo%p.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_name_specified_format_characters_percent_n(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['foo%n.html'], ['foo%n.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|
|
|
|
def test_generate_single_html_name_specified_format_characters_percent_percent(self):
|
2014-11-14 12:29:36 +00:00
|
|
|
self.run_test_case('2-pages.pdf', ['foo%%.html'], ['foo%%.html'])
|
2013-03-17 05:08:06 +00:00
|
|
|
|