~account-report-core-editor/account-financial-report/7.0-git

« back to all changes in this revision

Viewing changes to mis_builder/tests/test_mis_builder.py

  • Committer: Stéphane Bidoul (ACSONE)
  • Date: 2015-12-09 10:04:31 UTC
  • mfrom: (119.2.184)
  • Revision ID: git-v1:d7b417a5848e46d0e8460f84ddbe0fc090647962
Merge pull request #90 from acsone/7.0-mis_builder-lmi-2

7.0 mis builder backport from 8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
25
import openerp.tests.common as common
 
26
 
 
27
from ..models import mis_builder
 
28
 
 
29
 
 
30
class test_mis_builder(common.TransactionCase):
 
31
 
 
32
    def setUp(self):
 
33
        super(test_mis_builder, self).setUp()
 
34
 
 
35
    def test_datetime_conversion(self):
 
36
        date_to_convert = '2014-07-05'
 
37
        date_time_convert = mis_builder._utc_midnight(
 
38
            date_to_convert, 'Europe/Brussels')
 
39
        self.assertEqual(date_time_convert, '2014-07-04 22:00:00',
 
40
                         'The converted date time convert must contains hour')
 
41
        date_time_convert = mis_builder._utc_midnight(
 
42
            date_to_convert, 'Europe/Brussels', add_day=1)
 
43
        self.assertEqual(date_time_convert, '2014-07-05 22:00:00',
 
44
                         'The converted date time convert must contains hour')
 
45
        date_time_convert = mis_builder._utc_midnight(
 
46
            date_to_convert, 'US/Pacific')
 
47
        self.assertEqual(date_time_convert, '2014-07-05 07:00:00',
 
48
                         'The converted date time convert must contains hour')
 
49
        date_time_convert = mis_builder._utc_midnight(
 
50
            date_to_convert, 'US/Pacific', add_day=1)
 
51
        self.assertEqual(date_time_convert, '2014-07-06 07:00:00',
 
52
                         'The converted date time convert must contains hour')
 
53
 
 
54
    def test_fetch_query(self):
 
55
        # create a report on a model without company_id field :
 
56
        # account.analytic.balance
 
57
        data = self.registry('mis.report.instance').compute(
 
58
            self.cr, self.uid,
 
59
            self.ref('mis_builder.mis_report_instance_test'))
 
60
        self.assertDictContainsSubset(
 
61
            {'content':
 
62
                [{'kpi_name': u'total test',
 
63
                  'default_style': False,
 
64
                  'cols': [{'period_id': self.ref('mis_builder.'
 
65
                                                  'mis_report_instance_'
 
66
                                                  'period_test'),
 
67
                            'style': None,
 
68
                            'default_style': None,
 
69
                            'suffix': False,
 
70
                            'expr': u'len(test)',
 
71
                            'val_c': u'total_test = len(test)',
 
72
                            'val': 0,
 
73
                            'val_r': u'0\xa0',
 
74
                            'is_percentage': False,
 
75
                            'dp': 0,
 
76
                            'drilldown': False}]
 
77
                  }],
 
78
             'header':
 
79
                 [{'kpi_name': '',
 
80
                   'cols': [{'date': '07/31/2014',
 
81
                             'name': u'today'}]
 
82
                   }],
 
83
             }, data)