You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. # Copyright 2017 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. import base64
  4. from datetime import date
  5. from dateutil import relativedelta
  6. from odoo import fields
  7. from odoo.tests.common import TransactionCase
  8. class TestAccountExportCsv(TransactionCase):
  9. def setUp(self):
  10. super(TestAccountExportCsv, self).setUp()
  11. self.report_wizard = self.env["account.csv.export"]
  12. today_dt = date.today()
  13. next_month_date = today_dt + relativedelta.relativedelta(months=1)
  14. self.report_date_start = fields.Date.to_string(today_dt)
  15. self.report_date_end = fields.Date.to_string(next_month_date)
  16. def test_1(self):
  17. report_wizard = self.report_wizard.create(
  18. {"date_start": self.report_date_start, "date_end": self.report_date_end}
  19. )
  20. report_wizard.action_manual_export_account()
  21. def test_2(self):
  22. report_wizard = self.report_wizard.create(
  23. {"date_start": self.report_date_start, "date_end": self.report_date_end}
  24. )
  25. report_wizard.action_manual_export_analytic()
  26. def test_3(self):
  27. report_wizard = self.report_wizard.create(
  28. {"date_start": self.report_date_start, "date_end": self.report_date_end}
  29. )
  30. report_wizard.action_manual_export_journal_entries()
  31. def test_file_content(self):
  32. report_wizard = self.report_wizard.create(
  33. {
  34. "date_start": "2000-01-01",
  35. "date_end": "2200-01-01",
  36. }
  37. )
  38. report_wizard.action_manual_export_journal_entries()
  39. res = base64.decodebytes(report_wizard.data)
  40. line_number = self.env["account.move.line"].search_count([])
  41. # check the number of lines in file: include header + EOF line
  42. self.assertEqual(len(res.decode().split("\r\n")), line_number + 2)