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.

52 lines
1.8 KiB

  1. # Copyright 2017 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from datetime import date
  4. from dateutil import relativedelta
  5. import base64
  6. from odoo.tests.common import TransactionCase
  7. from odoo import fields
  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,
  19. 'date_end': self.report_date_end
  20. })
  21. report_wizard.action_manual_export_account()
  22. def test_2(self):
  23. report_wizard = self.report_wizard.create({
  24. 'date_start': self.report_date_start,
  25. 'date_end': self.report_date_end
  26. })
  27. report_wizard.action_manual_export_analytic()
  28. def test_3(self):
  29. report_wizard = self.report_wizard.create({
  30. 'date_start': self.report_date_start,
  31. 'date_end': self.report_date_end
  32. })
  33. report_wizard.action_manual_export_journal_entries()
  34. def test_file_content(self):
  35. report_wizard = self.report_wizard.create({
  36. "date_start": "2000-01-01",
  37. "date_end": "2200-01-01",
  38. })
  39. report_wizard.action_manual_export_journal_entries()
  40. res = base64.decodestring(report_wizard.data)
  41. line_number = self.env["account.move.line"].search_count([])
  42. # check the number of lines in file: include header + EOF line
  43. self.assertEqual(len(res.decode().split("\r\n")), line_number + 2)