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.

63 lines
2.7 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 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 a model without company_id field :
  29. # account.analytic.balance
  30. data = self.registry('mis.report.instance').compute(
  31. self.cr, self.uid,
  32. self.ref('mis_builder.mis_report_instance_test'))
  33. self.assertDictContainsSubset(
  34. {'content':
  35. [{'kpi_name': u'total test',
  36. 'default_style': False,
  37. 'cols': [{'period_id': self.ref('mis_builder.'
  38. 'mis_report_instance_'
  39. 'period_test'),
  40. 'style': None,
  41. 'prefix': False,
  42. 'suffix': False,
  43. 'expr': 'len(test)',
  44. 'val_c': 'total_test = len(test)',
  45. 'val': 0,
  46. 'val_r': u'\u202f0\xa0',
  47. 'is_percentage': False,
  48. 'dp': 0,
  49. 'drilldown': False}]
  50. }],
  51. 'header':
  52. [{'kpi_name': '',
  53. 'cols': [{'date': '07/31/2014',
  54. 'name': u'today'}]
  55. }],
  56. }, data)