forked from Techsystech/web
[ADD] Tests
parent
1611185af8
commit
998843d531
|
@ -28,3 +28,4 @@
|
|||
#
|
||||
|
||||
from . import web_shortcut
|
||||
from . import ir_ui_menu
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from . import test_web_shortcut
|
|
@ -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)
|
Loading…
Reference in New Issue