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.

65 lines
4.0 KiB

  1. #==============================================================================
  2. # =
  3. # mis_builder module for OpenERP, Management Information System Builder
  4. # Copyright (C) 2014 ACSONE SA/NV (<http://acsone.eu>)
  5. # =
  6. # This file is a part of mis_builder
  7. # =
  8. # mis_builder is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License v3 or later
  10. # as published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. # =
  13. # mis_builder is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License v3 or later for more details.
  17. # =
  18. # You should have received a copy of the GNU Affero General Public License
  19. # v3 or later along with this program.
  20. # If not, see <http://www.gnu.org/licenses/>.
  21. # =
  22. #==============================================================================
  23. import openerp.tests.common as common
  24. from openerp.addons.mis_builder import models
  25. from collections import OrderedDict
  26. DB = common.DB
  27. ADMIN_USER_ID = common.ADMIN_USER_ID
  28. class mis_builder_test(common.TransactionCase):
  29. def setUp(self):
  30. super(mis_builder_test, self).setUp()
  31. def test_datetime_conversion(self):
  32. date_to_convert = '2014-07-05'
  33. date_time_convert = models.mis_builder._utc_midnight(date_to_convert, 'Europe/Brussels')
  34. self.assertEqual(date_time_convert, '2014-07-04 22:00:00', 'The converted date time convert must contains hour')
  35. date_time_convert = models.mis_builder._utc_midnight(date_to_convert, 'Europe/Brussels', add_day=1)
  36. self.assertEqual(date_time_convert, '2014-07-05 22:00:00', 'The converted date time convert must contains hour')
  37. date_time_convert = models.mis_builder._utc_midnight(date_to_convert, 'US/Pacific')
  38. self.assertEqual(date_time_convert, '2014-07-05 07:00:00', 'The converted date time convert must contains hour')
  39. date_time_convert = models.mis_builder._utc_midnight(date_to_convert, 'US/Pacific', add_day=1)
  40. self.assertEqual(date_time_convert, '2014-07-06 07:00:00', 'The converted date time convert must contains hour')
  41. def test_fetch_query(self):
  42. # create a report on a model without company_id field : account.analytic.balance
  43. data = self.registry('mis.report.instance').compute(self.cr, self.uid, self.ref('mis_builder.mis_report_instance_test'))
  44. self.assertDictContainsSubset({'content': OrderedDict([(u'total_test',
  45. {'kpi_name': u'total test',
  46. 'cols': [{'style': None,
  47. 'val_c': None,
  48. 'val': 0,
  49. 'val_r': '0 '}]})]),
  50. 'header': OrderedDict([('',
  51. {'kpi_name': '',
  52. 'cols': [{'date': '2014-07-31',
  53. 'name': u'today'}]
  54. })])
  55. }, data)
  56. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: