示例#1
0
 def test_event_handler_registration(self):
     global_func_mock = Mock()
     handler_all()(global_func_mock)
     func_mock = Mock()
     handler("foo")(func_mock)
     event = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     self._call_handlers("bar.foo", {"data": "foo"})  # not handled
     self.assertEqual(2, global_func_mock.call_count)  # called each time
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)
 def test_event_handler_registration(self):
     global_func_mock = Mock()
     handler_all()(global_func_mock)
     func_mock = Mock()
     handler("foo")(func_mock)
     event = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     self._call_handlers("bar.foo", {"data": "foo"})  # not handled
     self.assertEqual(2, global_func_mock.call_count)  # called each time
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)
示例#3
0
	def test_event_subtype_handler_registration(self):
		global_func_mock = Mock()
		handler_all()(global_func_mock)
		func_mock = Mock()
		handler("foo.bar")(func_mock)
		event1 = self._call_handlers("foo.bar", {"data": "foo"})  # handled
		event2 = self._call_handlers("foo.bar.wib", {"data": "foo"})  # handled
		self._call_handlers("foo.baz", {"data": "foo"})  # not handled
		self.assertEqual(3, global_func_mock.call_count)  # called each time
		self.assertEqual(2, func_mock.call_count)
		func_mock.assert_has_calls([call(event=event1), call(event=event2)])
 def test_event_subtype_handler_registration(self):
     global_func_mock = Mock()
     handler_all()(global_func_mock)
     func_mock = Mock()
     handler("foo.bar")(func_mock)
     event1 = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     event2 = self._call_handlers("foo.bar.wib", {"data": "foo"})  # handled
     self._call_handlers("foo.baz", {"data": "foo"})  # not handled
     self.assertEqual(3, global_func_mock.call_count)  # called each time
     self.assertEqual(2, func_mock.call_count)
     func_mock.assert_has_calls([call(event=event1), call(event=event2)])
示例#5
0
 def test_global_handler_registration(self):
     func_mock = Mock()
     handler_all()(func_mock)
     event = self._call_handlers("wib.ble", {"data": "foo"})  # handled
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)
 def test_global_handler_registration_with_function(self):
     func_mock = Mock()
     handler_all(func_mock)
     event = self._call_handlers("wib.ble", {"data": "foo"})  # handled
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)
示例#7
0
 def test_global_handler_registration(self):
     func_mock = Mock()
     handler_all()(func_mock)
     self._call_handlers("wib.ble", {"data": "foo"})  # handled
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(ANY, ANY, "wib", "ble")