Exemplo n.º 1
0
# 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):
Exemplo n.º 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
Exemplo n.º 3
0
# 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
Exemplo n.º 4
0
# 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
Exemplo n.º 5
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('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)
Exemplo n.º 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)

Exemplo n.º 7
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)