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.

78 lines
3.9 KiB

11 years ago
11 years ago
  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(
  34. date_to_convert, 'Europe/Brussels')
  35. self.assertEqual(date_time_convert, '2014-07-04 22:00:00',
  36. 'The converted date time convert must contains hour')
  37. date_time_convert = models.mis_builder._utc_midnight(
  38. date_to_convert, 'Europe/Brussels', add_day=1)
  39. self.assertEqual(date_time_convert, '2014-07-05 22:00:00',
  40. 'The converted date time convert must contains hour')
  41. date_time_convert = models.mis_builder._utc_midnight(
  42. date_to_convert, 'US/Pacific')
  43. self.assertEqual(date_time_convert, '2014-07-05 07:00:00',
  44. 'The converted date time convert must contains hour')
  45. date_time_convert = models.mis_builder._utc_midnight(
  46. date_to_convert, 'US/Pacific', add_day=1)
  47. self.assertEqual(date_time_convert, '2014-07-06 07:00:00',
  48. 'The converted date time convert must contains hour')
  49. def test_fetch_query(self):
  50. # create a report on a model without company_id field :
  51. # account.analytic.balance
  52. data = self.registry('mis.report.instance').compute(
  53. self.cr, self.uid,
  54. self.ref('mis_builder.mis_report_instance_test'))
  55. self.assertDictContainsSubset(
  56. {'content':
  57. OrderedDict([(u'total_test',
  58. {'kpi_name': u'total test',
  59. 'cols': [{'style': None,
  60. 'val_c': None,
  61. 'val': 0,
  62. 'val_r': '0 '}]})]),
  63. 'header': OrderedDict([('',
  64. {'kpi_name': '',
  65. 'cols': [{'date': '2014-07-31',
  66. 'name': u'today'}]
  67. })])
  68. }, data)
  69. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: