# Path: pt_law_parser/parser.py
# def parse_document(file_name):
# 
#     rsrcmgr = PDFResourceManager(caching=True)
# 
#     fp = file(file_name, 'rb')
# 
#     device = LawConverter(rsrcmgr, laparams=LAOrganizer())
# 
#     interpreter = PDFPageInterpreter(rsrcmgr, device)
#     for page in PDFPage.get_pages(fp):
#         interpreter.process_page(page)
#     fp.close()
# 
#     return device
# 
# Path: tests/test_basic.py
# class TestDocument(unittest.TestCase):
# 
#     def get_expected(self, file_name):
#         with open(file_name+'.html') as my_file:
#             return my_file.read().decode("UTF-8")
# 
#     def setUp(self):
#         self.rsrcmgr = PDFResourceManager(caching=True)
#         params = LAOrganizer()
#         self.device = LawConverter(self.rsrcmgr, laparams=params)
# 
#     def _run_test(self, file_name, pages):
# 
#         fp = file(file_name, 'rb')
# 
#         interpreter = PDFPageInterpreter(self.rsrcmgr, self.device)
#         for page in PDFPage.get_pages(fp, pagenos=pages):
#             interpreter.process_page(page)
#         fp.close()
# 
#     def _print_result(self, file_name='s.html'):
#         """
#         Method to print the result of the test to a file, to inspection.
#         """
#         # to see lines, add <style>table, th, td {border: 1px solid black;
#         # border-collapse: collapse;} </style>
#         with open(file_name, 'w') as f:
#             f.write(self.device.as_html().encode('utf-8'))


import unittest
from pt_law_parser.parser import parse_document
from tests.test_basic import TestDocument
        self.assertEqual(14 + 13 + 4 + 5 + 0 + 0 + 2 + 0 + 5 + 21 + 6 + 18 + 8,
                         len(device.titles))

    def test_108839(self):
        """
        Document from 1998.
        """
        device = parse_document('tests/samples/108839.pdf')

        self.assertEqual(27, len(device.meta.pages))

        self.assertEqual(4 + 14 + 12 + 12 + 16 + 18 + 16 + 21 + 16 + 16 + 20 +
                         16 + 16 + 20 + 12 + 12 + 18 + 18 + 22 + 24 + 6 + 24 +
                         20 + 16 + 23 + 26 + 22,
                         len(device.titles))

    def test_113604(self):
        """
        Document from 2000.
        """
        device = parse_document('tests/samples/113604.pdf')

        self.assertEqual(4, len(device.meta.pages))

        self.assertEqual(15 + 2 + 3, len(device.titles))

    def test_116008(self):
        """
        Document from 2001.
        """

# Path: pt_law_parser/parser.py
# def parse_document(file_name):
# 
#     rsrcmgr = PDFResourceManager(caching=True)
# 
#     fp = file(file_name, 'rb')
# 
#     device = LawConverter(rsrcmgr, laparams=LAOrganizer())
# 
#     interpreter = PDFPageInterpreter(rsrcmgr, device)
#     for page in PDFPage.get_pages(fp):
#         interpreter.process_page(page)
#     fp.close()
# 
#     return device
# 
# Path: tests/test_basic.py
# class TestDocument(unittest.TestCase):
# 
#     def get_expected(self, file_name):
#         with open(file_name+'.html') as my_file:
#             return my_file.read().decode("UTF-8")
# 
#     def setUp(self):
#         self.rsrcmgr = PDFResourceManager(caching=True)
#         params = LAOrganizer()
#         self.device = LawConverter(self.rsrcmgr, laparams=params)
# 
#     def _run_test(self, file_name, pages):
# 
#         fp = file(file_name, 'rb')
# 
#         interpreter = PDFPageInterpreter(self.rsrcmgr, self.device)
#         for page in PDFPage.get_pages(fp, pagenos=pages):
#             interpreter.process_page(page)
#         fp.close()
# 
#     def _print_result(self, file_name='s.html'):
#         """
#         Method to print the result of the test to a file, to inspection.
#         """
#         # to see lines, add <style>table, th, td {border: 1px solid black;
#         # border-collapse: collapse;} </style>
#         with open(file_name, 'w') as f:
#             f.write(self.device.as_html().encode('utf-8'))


# Path: tests/test_parser.py
import unittest
from pt_law_parser.parser import parse_document
from tests.test_basic import TestDocument

        self.assertEqual(14 + 13 + 4 + 5 + 0 + 0 + 2 + 0 + 5 + 21 + 6 + 18 + 8,
                         len(device.titles))

    def test_108839(self):
        """
        Document from 1998.
        """
        device = parse_document('tests/samples/108839.pdf')

        self.assertEqual(27, len(device.meta.pages))

        self.assertEqual(4 + 14 + 12 + 12 + 16 + 18 + 16 + 21 + 16 + 16 + 20 +
                         16 + 16 + 20 + 12 + 12 + 18 + 18 + 22 + 24 + 6 + 24 +
                         20 + 16 + 23 + 26 + 22,
                         len(device.titles))

    def test_113604(self):
        """
        Document from 2000.
        """
        device = parse_document('tests/samples/113604.pdf')

        self.assertEqual(4, len(device.meta.pages))

        self.assertEqual(15 + 2 + 3, len(device.titles))

    def test_116008(self):
        """
        Document from 2001.
        """

        device = parse_document('tests/samples/116008.pdf')