Ejemplo n.º 1
0
	def test_event_handle_registation_with_list_of_strings(self):
		func_mock = Mock()
		handler("foo", "bar")(func_mock)
		event1 = self._call_handlers("foo.bar", {"data": "foo"})  # handled
		event2 = self._call_handlers("bar.foo", {"data": "bar"})  # handled
		self.assertEqual(2, func_mock.call_count)
		func_mock.assert_has_calls([call(event=event1), call(event=event2)])
Ejemplo n.º 2
0
 def test_event_handle_registation_with_list_of_strings(self):
     func_mock = Mock()
     handler("foo", "bar")(func_mock)
     event1 = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     event2 = self._call_handlers("bar.foo", {"data": "bar"})  # handled
     self.assertEqual(2, func_mock.call_count)
     func_mock.assert_has_calls([call(event=event1), call(event=event2)])
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)])
Ejemplo n.º 6
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)])
Ejemplo n.º 7
0
 def test_event_handle_registation_with_string(self):
     func_mock = Mock()
     handler("foo")(func_mock)
     event = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)
Ejemplo n.º 8
0
 def test_event_handle_registation_with_string(self):
     func_mock = Mock()
     handler("foo")(func_mock)
     event = self._call_handlers("foo.bar", {"data": "foo"})  # handled
     self.assertEqual(1, func_mock.call_count)
     func_mock.assert_called_with(event=event)