From d07b09dd8776c09c6036e1a945df7231baa3515c Mon Sep 17 00:00:00 2001 From: Mathias Markl Date: Fri, 19 Jan 2018 14:01:30 +0100 Subject: [PATCH] test --- muk_web_client_refresh/tests/__init__.py | 23 ++++++ muk_web_client_refresh/tests/test_refresh.py | 73 ++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 muk_web_client_refresh/tests/__init__.py create mode 100644 muk_web_client_refresh/tests/test_refresh.py diff --git a/muk_web_client_refresh/tests/__init__.py b/muk_web_client_refresh/tests/__init__.py new file mode 100644 index 0000000..f62e48e --- /dev/null +++ b/muk_web_client_refresh/tests/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# Copyright (C) 2017 MuK IT GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import test_refresh + diff --git a/muk_web_client_refresh/tests/test_refresh.py b/muk_web_client_refresh/tests/test_refresh.py new file mode 100644 index 0000000..a0daece --- /dev/null +++ b/muk_web_client_refresh/tests/test_refresh.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# Copyright (C) 2017 MuK IT GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +import os +import base64 +import unittest + +from contextlib import closing + +from odoo import _ +from odoo.tests import common + +class RefreshTestCase(common.TransactionCase): + + at_install = False + post_install = True + + def setUp(self): + super(RefreshTestCase, self).setUp() + self.model = self.env['ir.model'].sudo() + self.bus = self.env['bus.bus'].sudo() + self.rule = self.env['muk_web_client_refresh.rule'].sudo() + + def tearDown(self): + super(RefreshTestCase, self).tearDown() + + def test_refresh_rule(self): + start = self.bus.search([], count=True) + model = self.model.search([('model', '=', 'ir.logging')], limit=1) + self.rule.create({ + 'name': "TestRule", + 'model': model.id, + 'refresh_create': True, + 'refresh_write': True, + 'refresh_unlink': True}) + log = self.logging.create({ + 'name': "Test", + 'type': "server", + 'message': "Test", + 'path': "/", + 'func': "Test", + 'line': "1", + }) + create = self.bus.search([], count=True) + self.assertTrue(start < create) + log.write({'name': "Rename"}) + write = self.bus.search([], count=True) + self.assertTrue(write > create) + log.unlink() + delete = self.bus.search([], count=True) + self.assertTrue(write < delete) + + + + \ No newline at end of file