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.

72 lines
3.0 KiB

9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. import openerp.tests.common as common
  5. from ..models import mis_builder
  6. class TestMisBuilder(common.TransactionCase):
  7. def setUp(self):
  8. super(TestMisBuilder, self).setUp()
  9. def test_datetime_conversion(self):
  10. date_to_convert = '2014-07-05'
  11. date_time_convert = mis_builder._utc_midnight(
  12. date_to_convert, 'Europe/Brussels')
  13. self.assertEqual(date_time_convert, '2014-07-04 22:00:00',
  14. 'The converted date time convert must contains hour')
  15. date_time_convert = mis_builder._utc_midnight(
  16. date_to_convert, 'Europe/Brussels', add_day=1)
  17. self.assertEqual(date_time_convert, '2014-07-05 22:00:00',
  18. 'The converted date time convert must contains hour')
  19. date_time_convert = mis_builder._utc_midnight(
  20. date_to_convert, 'US/Pacific')
  21. self.assertEqual(date_time_convert, '2014-07-05 07:00:00',
  22. 'The converted date time convert must contains hour')
  23. date_time_convert = mis_builder._utc_midnight(
  24. date_to_convert, 'US/Pacific', add_day=1)
  25. self.assertEqual(date_time_convert, '2014-07-06 07:00:00',
  26. 'The converted date time convert must contains hour')
  27. def test_fetch_query(self):
  28. # create a report on account.analytic.line
  29. data = self.registry('mis.report.instance').compute(
  30. self.cr, self.uid,
  31. self.ref('mis_builder.mis_report_instance_test'))
  32. self.assertDictContainsSubset(
  33. {'content':
  34. [{'kpi_name': u'total test',
  35. 'default_style': '',
  36. 'default_xlsx_style': {},
  37. 'cols': [{'period_id': self.ref('mis_builder.'
  38. 'mis_report_instance_'
  39. 'period_test'),
  40. 'style': '',
  41. 'xlsx_style': {},
  42. 'prefix': False,
  43. 'suffix': False,
  44. 'expr': u'len(test)',
  45. 'val_c': u'total_test = len(test)',
  46. 'val': 0,
  47. 'val_r': u'\u202f0\xa0',
  48. 'is_percentage': False,
  49. 'dp': 0,
  50. 'drilldown': False}]
  51. }],
  52. 'header':
  53. [{'kpi_name': '',
  54. 'cols': [{'date': '07/31/2014',
  55. 'colspan': 1,
  56. 'name': u'today',
  57. }],
  58. },
  59. {'kpi_name': '',
  60. 'cols': [{'colspan': 1,
  61. 'name': '',
  62. }],
  63. },
  64. ],
  65. }, data)