test_parser_ingdiba.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. import pytest
  3. import os
  4. import dingguo.parser.ingdiba
  5. project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
  6. test_data_path = os.path.join(project_root_path, 'tests', 'data', 'ing-diba')
  7. def test_ingdiba_pdf_file_to_text_purchase():
  8. pdf_name = 'ING-DiBa_Postbox_2013-03-25_WP-Kauf - 60631041.pdf'
  9. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  10. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  11. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  12. def test_ingdiba_pdf_file_to_text_tax():
  13. pdf_name = 'ING-DiBa_Postbox_2013-12-27_KESt auf Erträge ausländischer Fonds.pdf'
  14. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  15. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  16. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  17. def test_ingdiba_pdf_file_to_text_statement():
  18. pdf_name = 'ING-DiBa_Postbox_2014-01-01_Depotauszug - 60631041.pdf'
  19. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  20. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  21. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  22. def test_ingdiba_pdf_file_to_text_divestiture():
  23. pdf_name = 'ING-DiBa_Postbox_2014-02-07_WP-Verkauf - 60631041.pdf'
  24. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  25. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  26. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  27. def test_ingdiba_pdf_file_to_text_loss_compensation():
  28. pdf_name = 'ING-DiBa_Postbox_2014-04-03_Verlustausgleich 2013.pdf'
  29. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  30. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  31. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  32. @pytest.mark.xfail(raises=IndexError)
  33. def test_ingdiba_pdf_file_to_text_loss_compensation_single_page():
  34. pdf_name = 'ING-DiBa_Postbox_2016-04-28_Verlustausgleich.pdf'
  35. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  36. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  37. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')
  38. def test_ingdiba_pdf_file_to_text_dividend_distribution():
  39. pdf_name = 'ING-DiBa_Postbox_2014-04-09_Jährl. Bestätigung Ausschüttung Fonds.pdf'
  40. with open(os.path.join(test_data_path, pdf_name)) as pdf_file:
  41. with open(os.path.join(test_data_path, os.path.splitext(pdf_name)[0] + '.txt')) as text_file:
  42. assert dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(pdf_file) == text_file.read().decode('utf-8')