mock.sentinel.raw_msg

Here are the examples of the python api mock.sentinel.raw_msg taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

Example 1

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.net.endpoint.BaseEndpoint._get_container_instance')
    def test__build_header_no_context(self, mockgci):
        ep = ProcessEndpointUnitMixin(process=Mock())
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertIn('sender-name', header)
        self.assertIn('sender', header)
        self.assertIn('sender-type', header)
        self.assertNotIn('sender-service', header)
        self.assertIn('origin-container-id', header)

        self.assertEquals(header['sender-name'], ep._process.name)
        self.assertEquals(header['sender'], ep._process.id)
        self.assertEquals(header['sender-type'], ep._process.process_type)
        self.assertEquals(header['origin-container-id'], mockgci().id)

Example 2

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header')
    @patch('pyon.net.endpoint.RPCRequestEndpointUnit._build_header')
    def test__build_header(self, mockr, mockp):

        mockr.return_value = {'one':1, 'two':2}
        mockp.return_value = {'two':-2, 'three':3}

        ep = ProcessRPCRequestEndpointUnit()
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertEquals(header, {'one':1, 'two':-2, 'three':3})

Example 3

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header')
    @patch('pyon.net.endpoint.RPCResponseEndpointUnit._build_header')
    def test__build_header(self, mockr, mockp):

        mockr.return_value = {'one':1, 'two':2}
        mockp.return_value = {'two':-2, 'three':3}

        ep = ProcessRPCResponseEndpointUnit()
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertEquals(header, {'one':1, 'two':-2, 'three':3})

Example 4

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header')
    @patch('pyon.net.endpoint.PublisherEndpointUnit._build_header')
    def test_build_header(self, mockr, mockp):
        mockr.return_value = {'one':1, 'two':2}
        mockp.return_value = {'two':-2, 'three':3}

        ep = ProcessPublisherEndpointUnit()
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertEquals(header, {'one':1, 'two':-2, 'three':3})

Example 5

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header')
    @patch('pyon.net.endpoint.SubscriberEndpointUnit._build_header')
    def test__build_header(self, mockr, mockp):

        mockr.return_value = {'one':1, 'two':2}
        mockp.return_value = {'two':-2, 'three':3}

        ep = ProcessSubscriberEndpointUnit()
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertEquals(header, {'one':1, 'two':-2, 'three':3})

Example 6

Project: pyon
Source File: test_endpoint.py
View license
    @patch('pyon.net.endpoint.BaseEndpoint._get_container_instance')
    def test__build_header_service(self, mockgci):
        procmock = Mock()
        procmock.process_type = 'service'

        ep = ProcessEndpointUnitMixin(process=procmock)
        ep.channel = Mock(spec=SendChannel)
        header = ep._build_header(sentinel.raw_msg, {})

        self.assertIn('sender-name', header)
        self.assertIn('sender', header)
        self.assertIn('sender-type', header)
        self.assertIn('sender-service', header)
        self.assertIn('origin-container-id', header)

        self.assertEquals(header['sender-name'], ep._process.name)
        self.assertEquals(header['sender'], ep._process.id)
        self.assertEquals(header['sender-type'], ep._process.process_type)
        self.assertEquals(header['sender-service'], "%s,%s" % (ep.channel._send_name.exchange, procmock.name))
        self.assertEquals(header['origin-container-id'], mockgci().id)