示例#1
0
文件: test_hub.py 项目: celery/kombu
    def test_callback_for(self):
        reader, writer = Mock(), Mock()
        self.hub.readers = {6: reader}
        self.hub.writers = {7: writer}

        assert callback_for(self.hub, 6, READ) == reader
        assert callback_for(self.hub, 7, WRITE) == writer
        with pytest.raises(KeyError):
            callback_for(self.hub, 6, WRITE)
        assert callback_for(self.hub, 6, WRITE, 'foo') == 'foo'
示例#2
0
    def test_callback_for(self):
        reader, writer = Mock(), Mock()
        self.hub.readers = {6: reader}
        self.hub.writers = {7: writer}

        assert callback_for(self.hub, 6, READ) == reader
        assert callback_for(self.hub, 7, WRITE) == writer
        with pytest.raises(KeyError):
            callback_for(self.hub, 6, WRITE)
        assert callback_for(self.hub, 6, WRITE, 'foo') == 'foo'
示例#3
0
    def test_callback_for(self):
        hub = Hub()
        reader, writer = Mock(), Mock()
        hub.readers = {6: reader}
        hub.writers = {7: writer}

        self.assertEqual(callback_for(hub, 6, READ), reader)
        self.assertEqual(callback_for(hub, 7, WRITE), writer)
        with self.assertRaises(KeyError):
            callback_for(hub, 6, WRITE)
        self.assertEqual(callback_for(hub, 6, WRITE, 'foo'), 'foo')