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.

81 lines
3.5 KiB

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