test_gchr.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import unittest
  2. import pandas as pd
  3. from gchr.gchr import GCHR
  4. from gchr.gchr_bookings import GchrBookings
  5. from gchr.gchr_translate import TRANSLATE
  6. class TestGchr(unittest.TestCase):
  7. base_dir_1: str = "C:\\Projekte\\GCHR2_Testdaten\\Kunden\\Altermann"
  8. base_dir_2: str = "C:\\Projekte\\GCHR2_Testdaten\\Kunden\\Koenig-und-Partner"
  9. def test_single_booking_files(self):
  10. gchr = GCHR(self.base_dir_1)
  11. self.assertIsInstance(gchr.bookings, GchrBookings)
  12. self.assertEqual(len(gchr.bookings.account_bookings), 1)
  13. self.assertEqual(gchr.bookings.account_bookings[0].name, "GuV_Bilanz_Salden.csv")
  14. def test_multiple_booking_files(self):
  15. gchr = GCHR(self.base_dir_2)
  16. self.assertIsInstance(gchr.bookings, GchrBookings)
  17. self.assertEqual(len(gchr.bookings.account_bookings), 2)
  18. self.assertEqual(gchr.bookings.account_bookings[0].name, "GuV_Bilanz_Salden.csv")
  19. self.assertEqual(gchr.bookings.account_bookings[1].name, "GuV_Bilanz_Salden_deop03.csv")
  20. def test_translation_existing(self):
  21. gchr = GCHR(self.base_dir_1)
  22. df = gchr.df_translate
  23. self.assertIsInstance(df, pd.DataFrame)
  24. self.assertEqual(df.shape[1], 12)
  25. self.assertListEqual(list(df.columns), TRANSLATE)
  26. self.assertGreater(df.shape[0], 0, "Translation not empty")
  27. def test_all_periods(self):
  28. periods = GCHR.get_all_periods("2024-12-23")
  29. self.assertEqual(len(periods), 12)
  30. self.assertEqual(periods[0], ("2023", "12"))
  31. self.assertEqual(periods[-1], ("2024", "11"))