mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
Fix several issues
Fix error '... is not a table or foreign table' Fix view (colors + oe_highlight) Fix tests Fix README + manifest Fix back to draft Fix cron call + default values Use Postgres version 9.6 for travis builds
This commit is contained in:
committed by
David James
parent
1ff35f17f7
commit
334ec93514
@@ -2,56 +2,68 @@
|
||||
# Copyright 2017 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase, at_install, post_install
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tests.common import SingleTransactionCase, at_install, post_install
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
|
||||
|
||||
class TestBiSqlViewEditor(TransactionCase):
|
||||
@at_install(False)
|
||||
@post_install(True)
|
||||
class TestBiSqlViewEditor(SingleTransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBiSqlViewEditor, self).setUp()
|
||||
self.res_partner = self.env['res.partner']
|
||||
self.res_users = self.env['res.users']
|
||||
self.bi_sql_view = self.env['bi.sql.view']
|
||||
self.group_bi_user = self.env.ref(
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestBiSqlViewEditor, cls).setUpClass()
|
||||
|
||||
cls.res_partner = cls.env['res.partner']
|
||||
cls.res_users = cls.env['res.users']
|
||||
cls.bi_sql_view = cls.env['bi.sql.view']
|
||||
cls.group_bi_user = cls.env.ref(
|
||||
'sql_request_abstract.group_sql_request_manager')
|
||||
self.group_user = self.env.ref(
|
||||
cls.group_user = cls.env.ref(
|
||||
'base.group_user')
|
||||
self.view = self.bi_sql_view.create({
|
||||
cls.view = cls.bi_sql_view.create({
|
||||
'name': 'Partners View 2',
|
||||
'is_materialized': False,
|
||||
'is_materialized': True,
|
||||
'technical_name': 'partners_view_2',
|
||||
'query': "SELECT name as x_name, street as x_street,"
|
||||
"company_id as x_company_id FROM res_partner "
|
||||
"ORDER BY name"
|
||||
})
|
||||
self.company = self.env.ref('base.main_company')
|
||||
cls.company = cls.env.ref('base.main_company')
|
||||
# Create bi user
|
||||
self.bi_user = self._create_user('bi_user', [self.group_bi_user],
|
||||
self.company)
|
||||
self.no_bi_user = self._create_user('no_bi_user', [self.group_user],
|
||||
self.company)
|
||||
cls.bi_user = cls._create_user('bi_user', cls.group_bi_user,
|
||||
cls.company)
|
||||
cls.no_bi_user = cls._create_user('no_bi_user', cls.group_user,
|
||||
cls.company)
|
||||
|
||||
def _create_user(self, login, groups, company):
|
||||
@classmethod
|
||||
def _create_user(cls, login, groups, company):
|
||||
"""Create a user."""
|
||||
group_ids = [group.id for group in groups]
|
||||
user = self.res_users.create({
|
||||
user = cls.res_users.create({
|
||||
'name': 'Test BI User',
|
||||
'login': login,
|
||||
'password': 'demo',
|
||||
'email': 'example@yourcompany.com',
|
||||
'notify_email': 'none',
|
||||
'company_id': company.id,
|
||||
'groups_id': [(6, 0, group_ids)]
|
||||
'groups_id': [(6, 0, groups.ids)]
|
||||
})
|
||||
return user
|
||||
|
||||
@at_install(False)
|
||||
@post_install(True)
|
||||
def test_process_view(self):
|
||||
view = self.view
|
||||
self.assertEqual(view.state, 'draft', 'state not draft')
|
||||
view.button_validate_sql_expression()
|
||||
self.assertEqual(view.state, 'sql_valid', 'state not sql_valid')
|
||||
view.button_create_sql_view_and_model()
|
||||
self.assertEqual(view.state, 'model_valid', 'state not model_valid')
|
||||
view.button_create_ui()
|
||||
self.assertEqual(view.state, 'ui_valid', 'state not ui_valid')
|
||||
view.button_update_model_access()
|
||||
self.assertEqual(view.has_group_changed, False,
|
||||
'has_group_changed not False')
|
||||
cron_res = view.cron_id.method_direct_trigger()
|
||||
self.assertEqual(cron_res, True, 'something went wrong with the cron')
|
||||
|
||||
def test_copy(self):
|
||||
copy_view = self.view.copy()
|
||||
@@ -68,8 +80,10 @@ class TestBiSqlViewEditor(TransactionCase):
|
||||
'bi %s' % self.view.name)
|
||||
|
||||
def test_unlink(self):
|
||||
self.assertEqual(self.view.state, 'draft', 'state not draft')
|
||||
self.view.button_validate_sql_expression()
|
||||
self.assertEqual(self.view.state, 'ui_valid', 'state not ui_valid')
|
||||
with self.assertRaises(UserError):
|
||||
self.view.unlink()
|
||||
self.view.button_set_draft()
|
||||
self.view.unlink()
|
||||
res = self.bi_sql_view.search([('name', '=', 'Partners View 2')])
|
||||
self.assertEqual(len(res), 0, 'View not deleted')
|
||||
|
||||
Reference in New Issue
Block a user