Browse Source

[ADD] Tests

pull/564/head
tarteo 8 years ago
parent
commit
998843d531
  1. 1
      web_shortcut/models/__init__.py
  2. 13
      web_shortcut/models/ir_ui_menu.py
  3. 11
      web_shortcut/models/web_shortcut.py
  4. 1
      web_shortcut/tests/__init__.py
  5. 27
      web_shortcut/tests/test_web_shortcut.py

1
web_shortcut/models/__init__.py

@ -28,3 +28,4 @@
#
from . import web_shortcut
from . import ir_ui_menu

13
web_shortcut/models/ir_ui_menu.py

@ -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

11
web_shortcut/models/web_shortcut.py

@ -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

@ -0,0 +1 @@
from . import test_web_shortcut

27
web_shortcut/tests/test_web_shortcut.py

@ -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…
Cancel
Save