# -*- coding: utf-8 -*- import pytest import os import dingguo.parser.ingdiba project_root_path = os.path.realpath(os.path.join(__file__, '..', '..')) test_data_path = os.path.join(project_root_path, 'tests', 'data', 'ing-diba') def test_ingdiba_pdf_file_to_text_purchase(): pdf_name = 'ING-DiBa_Postbox_2013-03-25_WP-Kauf - 60631041.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') def test_ingdiba_pdf_file_to_text_tax(): pdf_name = 'ING-DiBa_Postbox_2013-12-27_KESt auf Erträge ausländischer Fonds.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') def test_ingdiba_pdf_file_to_text_statement(): pdf_name = 'ING-DiBa_Postbox_2014-01-01_Depotauszug - 60631041.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') def test_ingdiba_pdf_file_to_text_divestiture(): pdf_name = 'ING-DiBa_Postbox_2014-02-07_WP-Verkauf - 60631041.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') def test_ingdiba_pdf_file_to_text_loss_compensation(): pdf_name = 'ING-DiBa_Postbox_2014-04-03_Verlustausgleich 2013.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') @pytest.mark.xfail(raises=IndexError) def test_ingdiba_pdf_file_to_text_loss_compensation_single_page(): pdf_name = 'ING-DiBa_Postbox_2016-04-28_Verlustausgleich.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8') def test_ingdiba_pdf_file_to_text_dividend_distribution(): pdf_name = 'ING-DiBa_Postbox_2014-04-09_Jährl. Bestätigung Ausschüttung Fonds.pdf' with open(os.path.join(test_data_path, pdf_name)) as pdf_file: with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file: assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')