mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] Tests
This commit is contained in:
@@ -28,3 +28,4 @@
|
||||
#
|
||||
|
||||
from . import web_shortcut
|
||||
from . import ir_ui_menu
|
||||
|
||||
13
web_shortcut/models/ir_ui_menu.py
Normal file
13
web_shortcut/models/ir_ui_menu.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class IrUiView(models.Model):
|
||||
_inherit = 'ir.ui.menu'
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
res = super(IrUiView, self).unlink()
|
||||
shortcuts = self.env['web.shortcut'].search([('menu_id', '=', False)])
|
||||
for shortcut in shortcuts:
|
||||
shortcut.unlink()
|
||||
return res
|
||||
@@ -53,14 +53,3 @@ class WebShortcut(models.Model):
|
||||
)
|
||||
return res
|
||||
|
||||
|
||||
class IrUiView(models.Model):
|
||||
_inherit = 'ir.ui.menu'
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
res = super(IrUiView, self).unlink()
|
||||
shortcuts = self.env['web.shortcut'].search([('menu_id', '=', False)])
|
||||
for shortcut in shortcuts:
|
||||
shortcut.unlink()
|
||||
return res
|
||||
|
||||
1
web_shortcut/tests/__init__.py
Normal file
1
web_shortcut/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_web_shortcut
|
||||
27
web_shortcut/tests/test_web_shortcut.py
Normal file
27
web_shortcut/tests/test_web_shortcut.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from openerp.tests.common import HttpCase, TransactionCase
|
||||
|
||||
|
||||
class TestWebShortcut(TransactionCase):
|
||||
def setUp(self, *args, **kwargs):
|
||||
super(TestWebShortcut, self).setUp(*args, **kwargs)
|
||||
self.shortcut_obj = self.env['web.shortcut']
|
||||
self.menu_obj = self.env['ir.ui.menu']
|
||||
|
||||
self.menu = self.env.ref('base.menu_ir_property')
|
||||
self.user = self.env.ref('base.user_root')
|
||||
|
||||
self.shortcut_obj.search([('user_id', '=', self.user.id)]).unlink()
|
||||
|
||||
def test_web_shortcut(self):
|
||||
res = self.shortcut_obj.get_user_shortcuts()
|
||||
self.assertEqual(len(res), 0)
|
||||
self.shortcut_obj.create({
|
||||
'name': 'Test',
|
||||
'menu_id': self.menu.id,
|
||||
'user_id': self.env.user.id
|
||||
})
|
||||
res = self.shortcut_obj.get_user_shortcuts()
|
||||
self.assertEqual(len(res), 1)
|
||||
self.menu.unlink()
|
||||
res = self.shortcut_obj.get_user_shortcuts()
|
||||
self.assertEqual(len(res), 0)
|
||||
Reference in New Issue
Block a user