Ejemplo n.º 1
0
 def test_return_false_if_magic_attr_is_missing(self):
     self.assertFalse(
         dispatcher.is_message_handler(
             unittest.mock.sentinel.type_,
             unittest.mock.sentinel.from_,
             object()
         )
     )
Ejemplo n.º 2
0
    def test_works_with_is_message_handler(self):
        def cb():
            pass

        self.assertFalse(
            dispatcher.is_message_handler(
                unittest.mock.sentinel.type_,
                unittest.mock.sentinel.from_,
                cb,
            ))

        self.decorator(cb)

        self.assertTrue(
            dispatcher.is_message_handler(
                unittest.mock.sentinel.type_,
                unittest.mock.sentinel.from_,
                cb,
            ))
Ejemplo n.º 3
0
    def test_works_with_is_message_handler(self):
        def cb():
            pass

        self.assertFalse(
            dispatcher.is_message_handler(
                unittest.mock.sentinel.type_,
                unittest.mock.sentinel.from_,
                cb,
            )
        )

        self.decorator(cb)

        self.assertTrue(
            dispatcher.is_message_handler(
                unittest.mock.sentinel.type_,
                unittest.mock.sentinel.from_,
                cb,
            )
        )
Ejemplo n.º 4
0
    def test_return_false_if_token_not_in_magic_attr(self):
        m = unittest.mock.Mock()
        m._aioxmpp_service_handlers = [
            aioxmpp.service.HandlerSpec(
                (dispatcher._apply_message_handler,
                 (unittest.mock.sentinel.type2, unittest.mock.sentinel.from2)),
                require_deps=(dispatcher.SimpleMessageDispatcher, ))
        ]

        self.assertFalse(
            dispatcher.is_message_handler(unittest.mock.sentinel.type_,
                                          unittest.mock.sentinel.from_, m))
Ejemplo n.º 5
0
    def test_return_false_if_token_not_in_magic_attr(self):
        m = unittest.mock.Mock()
        m._aioxmpp_service_handlers = [
            aioxmpp.service.HandlerSpec(
                (dispatcher._apply_message_handler,
                 (unittest.mock.sentinel.type2,
                     unittest.mock.sentinel.from2)),
                require_deps=(
                    dispatcher.SimpleMessageDispatcher,
                )
            )
        ]

        self.assertFalse(
            dispatcher.is_message_handler(
                unittest.mock.sentinel.type_,
                unittest.mock.sentinel.from_,
                m
            )
        )
Ejemplo n.º 6
0
 def test_return_false_if_magic_attr_is_missing(self):
     self.assertFalse(
         dispatcher.is_message_handler(unittest.mock.sentinel.type_,
                                       unittest.mock.sentinel.from_,
                                       object()))