[REF] web_notify: Black python code

This commit is contained in:
laurent.corron
2019-11-14 15:39:25 +01:00
committed by David
parent dfbd67358c
commit 26880e30a6
3 changed files with 27 additions and 70 deletions

View File

@@ -4,21 +4,20 @@
import json
import mock
from odoo import exceptions
from odoo.addons.bus.models.bus import json_dump
from ..models.res_users import SUCCESS, DANGER, WARNING, INFO, DEFAULT
from odoo.tests import common
from odoo.addons.bus.models.bus import json_dump
from ..models.res_users import DANGER, DEFAULT, INFO, SUCCESS, WARNING
class TestResUsers(common.TransactionCase):
def test_notify_success(self):
bus_bus = self.env["bus.bus"]
domain = [
(
"channel",
"=",
json_dump(self.env.user.notify_success_channel_name),
)
("channel", "=", json_dump(self.env.user.notify_success_channel_name))
]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
@@ -30,13 +29,7 @@ class TestResUsers(common.TransactionCase):
def test_notify_danger(self):
bus_bus = self.env["bus.bus"]
domain = [
(
"channel",
"=",
json_dump(self.env.user.notify_danger_channel_name),
)
]
domain = [("channel", "=", json_dump(self.env.user.notify_danger_channel_name))]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
self.env.user.notify_danger(**test_msg)
@@ -48,11 +41,7 @@ class TestResUsers(common.TransactionCase):
def test_notify_warning(self):
bus_bus = self.env["bus.bus"]
domain = [
(
"channel",
"=",
json_dump(self.env.user.notify_warning_channel_name),
)
("channel", "=", json_dump(self.env.user.notify_warning_channel_name))
]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
@@ -64,9 +53,7 @@ class TestResUsers(common.TransactionCase):
def test_notify_info(self):
bus_bus = self.env["bus.bus"]
domain = [
("channel", "=", json_dump(self.env.user.notify_info_channel_name))
]
domain = [("channel", "=", json_dump(self.env.user.notify_info_channel_name))]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
self.env.user.notify_info(**test_msg)
@@ -78,11 +65,7 @@ class TestResUsers(common.TransactionCase):
def test_notify_default(self):
bus_bus = self.env["bus.bus"]
domain = [
(
"channel",
"=",
json_dump(self.env.user.notify_default_channel_name),
)
("channel", "=", json_dump(self.env.user.notify_default_channel_name))
]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
@@ -95,9 +78,7 @@ class TestResUsers(common.TransactionCase):
def test_notify_many(self):
# check that the notification of a list of users is done with
# a single call to the bus
with mock.patch(
"odoo.addons.bus.models.bus.ImBus.sendmany"
) as mockedSendMany:
with mock.patch("odoo.addons.bus.models.bus.ImBus.sendmany") as mockedSendMany:
users = self.env.user.search([(1, "=", 1)])
self.assertTrue(len(users) > 1)
users.notify_warning(message="message")