コード例 #1
0
ファイル: test_consumer.py プロジェクト: pombreda/gofer
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import Mock, patch

from gofer.devel import ipatch

from gofer.messaging.adapter.model import Message

with ipatch('qpid'):
    from gofer.messaging.adapter.qpid.consumer import Reader, BaseReader


class Empty(Exception):
    pass


class Queue(object):
    def __init__(self, name):
        self.name = name


class TestReader(TestCase):
    @patch('gofer.messaging.adapter.qpid.consumer.Connection')
    def test_init(self, connection):
コード例 #2
0
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import Mock, patch

from gofer.devel import ipatch

with ipatch('amqp'):
    from gofer.messaging.adapter.amqp.producer import build_message
    from gofer.messaging.adapter.amqp.producer import Sender, BaseSender


class TestBuildMessage(TestCase):
    @patch('gofer.messaging.adapter.amqp.producer.Message')
    def test_call(self, message):
        ttl = 10
        durable = False
        body = 'test-body'

        # test
        m = build_message(body, ttl, durable)

        # validation
コード例 #3
0
ファイル: test_consumer.py プロジェクト: darinlively/gofer
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

import select

from unittest import TestCase

from mock import Mock, patch

from gofer.devel import ipatch

from gofer.messaging.adapter.model import Message

with ipatch('amqp'):
    from gofer.messaging.adapter.amqp.consumer import Receiver, Inbox, Empty
    from gofer.messaging.adapter.amqp.consumer import Reader, BaseReader
    from gofer.messaging.adapter.amqp.consumer import DELIVERY_TAG


class Queue(object):

    def __init__(self, name):
        self.name = name


class ChannelError(Exception):

    def __init__(self, code):
        self.code = code
コード例 #4
0
ファイル: test_consumer.py プロジェクト: darinlively/gofer
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import Mock, patch

from gofer.devel import ipatch

from gofer.messaging.adapter.model import Message

with ipatch('proton'):
    from gofer.messaging.adapter.proton.consumer import Reader, BaseReader


class Timeout(Exception):
    pass


class Queue(object):

    def __init__(self, name):
        self.name = name


class LinkException(Exception):
    pass
コード例 #5
0
ファイル: test_model.py プロジェクト: jortel/gofer
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import patch, Mock

from gofer.devel import ipatch

with ipatch('qpid'):
    from gofer.messaging.adapter.qpid import model
    from gofer.messaging.adapter.qpid.model import Error, Method
    from gofer.messaging.adapter.qpid.model import Exchange, BaseExchange
    from gofer.messaging.adapter.qpid.model import Queue, BaseQueue


class TestError(TestCase):

    def test_init(self):
        code = 18
        description = '12345'
        error = Error(description, code)
        self.assertEqual(error.code, code)
        self.assertEqual(error.args[0], description)
コード例 #6
0
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import patch, Mock

from gofer.devel import ipatch

with ipatch('proton'):
    from gofer.messaging.adapter.proton import model
    from gofer.messaging.adapter.proton.model import Error, Method
    from gofer.messaging.adapter.proton.model import Exchange, BaseExchange
    from gofer.messaging.adapter.proton.model import Queue, BaseQueue


class TestError(TestCase):
    def test_init(self):
        code = 18
        description = '12345'
        error = Error(description, code)
        self.assertEqual(error.code, code)
        self.assertEqual(error.args[0], description)

コード例 #7
0
ファイル: test_model.py プロジェクト: pombredanne/gofer
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from unittest import TestCase

from mock import patch, Mock

from gofer.devel import ipatch

with ipatch("proton"):
    from gofer.messaging.adapter.proton import model
    from gofer.messaging.adapter.proton.model import Error, Method
    from gofer.messaging.adapter.proton.model import Exchange, BaseExchange
    from gofer.messaging.adapter.proton.model import Queue, BaseQueue


class TestError(TestCase):
    def test_init(self):
        code = 18
        description = "12345"
        error = Error(description, code)
        self.assertEqual(error.code, code)
        self.assertEqual(error.args[0], description)