Stéphane Bidoul
9 years ago
5 changed files with 79 additions and 78 deletions
-
18mis_builder/models/mis_report.py
-
3mis_builder/tests/__init__.py
-
39mis_builder/tests/test_fetch_query.py
-
72mis_builder/tests/test_mis_builder.py
-
25mis_builder/tests/test_utc_midnight.py
@ -0,0 +1,39 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2014-2016 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import openerp.tests.common as common |
||||
|
|
||||
|
|
||||
|
class TestFetchQuery(common.TransactionCase): |
||||
|
|
||||
|
def test_fetch_query(self): |
||||
|
# create a report on account.analytic.line |
||||
|
data = self.registry('mis.report.instance').compute( |
||||
|
self.cr, self.uid, |
||||
|
self.ref('mis_builder.mis_report_instance_test')) |
||||
|
self.assertEquals( |
||||
|
{'content': |
||||
|
[{'description': u'total test', |
||||
|
'comment': '', |
||||
|
'style': None, |
||||
|
'parent_row_id': None, |
||||
|
'row_id': u'total_test', |
||||
|
'cols': [{'val': 0, |
||||
|
'val_r': u'\xa00\xa0', |
||||
|
'val_c': u'total_test = len(test)', |
||||
|
}] |
||||
|
}], |
||||
|
'header': |
||||
|
[{'cols': [{'comment': '07/31/2014', |
||||
|
'colspan': 1, |
||||
|
'description': u'today', |
||||
|
}], |
||||
|
}, |
||||
|
{'cols': [{'colspan': 1, |
||||
|
'description': '', |
||||
|
'comment': '', |
||||
|
}], |
||||
|
}, |
||||
|
], |
||||
|
}, data) |
@ -1,72 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# © 2014-2015 ACSONE SA/NV (<http://acsone.eu>) |
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
||||
|
|
||||
import openerp.tests.common as common |
|
||||
|
|
||||
from ..models import mis_builder |
|
||||
|
|
||||
|
|
||||
class TestMisBuilder(common.TransactionCase): |
|
||||
|
|
||||
def setUp(self): |
|
||||
super(TestMisBuilder, self).setUp() |
|
||||
|
|
||||
def test_datetime_conversion(self): |
|
||||
date_to_convert = '2014-07-05' |
|
||||
date_time_convert = mis_builder._utc_midnight( |
|
||||
date_to_convert, 'Europe/Brussels') |
|
||||
self.assertEqual(date_time_convert, '2014-07-04 22:00:00', |
|
||||
'The converted date time convert must contains hour') |
|
||||
date_time_convert = mis_builder._utc_midnight( |
|
||||
date_to_convert, 'Europe/Brussels', add_day=1) |
|
||||
self.assertEqual(date_time_convert, '2014-07-05 22:00:00', |
|
||||
'The converted date time convert must contains hour') |
|
||||
date_time_convert = mis_builder._utc_midnight( |
|
||||
date_to_convert, 'US/Pacific') |
|
||||
self.assertEqual(date_time_convert, '2014-07-05 07:00:00', |
|
||||
'The converted date time convert must contains hour') |
|
||||
date_time_convert = mis_builder._utc_midnight( |
|
||||
date_to_convert, 'US/Pacific', add_day=1) |
|
||||
self.assertEqual(date_time_convert, '2014-07-06 07:00:00', |
|
||||
'The converted date time convert must contains hour') |
|
||||
|
|
||||
def test_fetch_query(self): |
|
||||
# create a report on account.analytic.line |
|
||||
data = self.registry('mis.report.instance').compute( |
|
||||
self.cr, self.uid, |
|
||||
self.ref('mis_builder.mis_report_instance_test')) |
|
||||
self.assertDictContainsSubset( |
|
||||
{'content': |
|
||||
[{'kpi_name': u'total test', |
|
||||
'default_style': '', |
|
||||
'default_xlsx_style': {}, |
|
||||
'cols': [{'period_id': self.ref('mis_builder.' |
|
||||
'mis_report_instance_' |
|
||||
'period_test'), |
|
||||
'style': '', |
|
||||
'xlsx_style': {}, |
|
||||
'prefix': False, |
|
||||
'suffix': False, |
|
||||
'expr': u'len(test)', |
|
||||
'val_c': u'total_test = len(test)', |
|
||||
'val': 0, |
|
||||
'val_r': u'\u202f0\xa0', |
|
||||
'is_percentage': False, |
|
||||
'dp': 0, |
|
||||
'drilldown': False}] |
|
||||
}], |
|
||||
'header': |
|
||||
[{'kpi_name': '', |
|
||||
'cols': [{'date': '07/31/2014', |
|
||||
'colspan': 1, |
|
||||
'name': u'today', |
|
||||
}], |
|
||||
}, |
|
||||
{'kpi_name': '', |
|
||||
'cols': [{'colspan': 1, |
|
||||
'name': '', |
|
||||
}], |
|
||||
}, |
|
||||
], |
|
||||
}, data) |
|
@ -0,0 +1,25 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2014-2015 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import openerp.tests.common as common |
||||
|
|
||||
|
from ..models.mis_report import _utc_midnight |
||||
|
|
||||
|
|
||||
|
class TestUtcMidnight(common.TransactionCase): |
||||
|
|
||||
|
def test_utc_midnight(self): |
||||
|
date_to_convert = '2014-07-05' |
||||
|
date_time_convert = _utc_midnight( |
||||
|
date_to_convert, 'Europe/Brussels') |
||||
|
self.assertEqual(date_time_convert, '2014-07-04 22:00:00') |
||||
|
date_time_convert = _utc_midnight( |
||||
|
date_to_convert, 'Europe/Brussels', add_day=1) |
||||
|
self.assertEqual(date_time_convert, '2014-07-05 22:00:00') |
||||
|
date_time_convert = _utc_midnight( |
||||
|
date_to_convert, 'US/Pacific') |
||||
|
self.assertEqual(date_time_convert, '2014-07-05 07:00:00') |
||||
|
date_time_convert = _utc_midnight( |
||||
|
date_to_convert, 'US/Pacific', add_day=1) |
||||
|
self.assertEqual(date_time_convert, '2014-07-06 07:00:00') |
Write
Preview
Loading…
Cancel
Save
Reference in new issue