Exemplo n.º 1
0
    def test_emit_throws(self):
        restore = conf.debug

        try:
            conf.debug = True
            emitter = Emitter()

            with pytest.raises(ValueError) as excinfo:
                emitter.emit('foo')
            assert '`operation` must not be empty' == str(excinfo.value)
        finally:
            conf.debug = restore
Exemplo n.º 2
0
    def event_from_callback(cls, event, **kwargs):
        events = []

        def cb(message):
            events.append(message)

        adapter = adapters.ListAdapter()
        transport = transports.Transport(
            adapter, worker_class=transports.Worker)
        emitter = Emitter(transport=transport, callbacks=[cb], **kwargs)

        emitter.emit(event)
        assert len(events) == 1

        event = events.pop()
        assert isinstance(event, Event)
        return event