deeejas hace 4 meses
padre
commit
b9fbe14698
Se han modificado 1 ficheros con 11 adiciones y 3 borrados
  1. 11 3
      tests/test_receipt.py

+ 11 - 3
tests/test_receipt.py

@@ -5,7 +5,8 @@ import unittest
 # import pyautogui as ag
 import requests
 import fitz
-import PyPDF2
+import pypdf
+from lxml import etree
 # import PyPDF225
 
 from receipt import Receipts
@@ -13,18 +14,25 @@ from receipt import Receipts
 class Test(unittest.TestCase):
     receipt = Receipts()
 
+    def test_xml(self):
+        xml = etree.parse('/home/deeejas/git/pyanaf/sample_files/D300_21480386_2021_02.xml')
+        root = xml.getroot()
+        print(root)
+        tree = xml.xpath('/xmlns:declaratie300/*', namespaces={'xmlns': 'mfp:anaf:dgti:d300:declaratie:v6'})
+        print(tree)
+
     def test_pdfread(self):
         self.receipt.pdf_reader('sample_files/202550755_17259191_D394_1_2020.pdf')
         print(self.receipt.mesaj.strip())
 
     def test_pypdf_read(self):
-        pdf = PyPDF2.PdfFileReader('sample_files/202550755_17259191_D394_1_2020.pdf')
+        pdf = pypdf.PdfReader('sample_files/202550755_17259191_D394_1_2020.pdf')
         pdf_page = pdf.getPage(0)
         text = pdf_page.extractText()
         print(text)
 
     def test_pypdf2_read(self):
-        pdf = PyPDF2.PdfFileReader('sample_files/202550755_17259191_D394_1_2020.pdf')
+        pdf = pypdf.PdfReader('sample_files/202550755_17259191_D394_1_2020.pdf')
         pdf_page = pdf.pages[0]
         text = pdf_page.extract_text()
         print(text)