-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_notifier.py
56 lines (37 loc) · 1.71 KB
/
test_notifier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
# Copyright 2018-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later
import unittest
from mock import Mock
from xivo_bus.resources.call_pickup.event import (
CreateCallPickupEvent,
DeleteCallPickupEvent,
EditCallPickupEvent,
)
from xivo_dao.alchemy.pickup import Pickup as CallPickup
from ..notifier import CallPickupNotifier
SYSCONFD_HANDLERS = {
'ipbx': ['module reload res_pjsip.so', 'module reload chan_sccp.so'],
'agentbus': [],
}
class TestCallPickupNotifier(unittest.TestCase):
def setUp(self):
self.bus = Mock()
self.sysconfd = Mock()
self.call_pickup = Mock(CallPickup, id=1234)
self.notifier = CallPickupNotifier(self.bus, self.sysconfd)
def test_when_call_pickup_created_then_event_sent_on_bus(self):
expected_event = CreateCallPickupEvent(self.call_pickup.id)
self.notifier.created(self.call_pickup)
self.bus.send_bus_event.assert_called_once_with(expected_event)
def test_when_call_pickup_edited_then_event_sent_on_bus(self):
expected_event = EditCallPickupEvent(self.call_pickup.id)
self.notifier.edited(self.call_pickup)
self.bus.send_bus_event.assert_called_once_with(expected_event)
def test_when_call_pickup_deleted_then_event_sent_on_bus(self):
expected_event = DeleteCallPickupEvent(self.call_pickup.id)
self.notifier.deleted(self.call_pickup)
self.bus.send_bus_event.assert_called_once_with(expected_event)
def test_when_call_pickup_deleted_then_sysconfd_event(self):
self.notifier.deleted(self.call_pickup)
self.sysconfd.exec_request_handlers.assert_called_once_with(SYSCONFD_HANDLERS)