當前位置: 首頁>>代碼示例>>Python>>正文


Python ProcessEndpointUnitMixin._build_header方法代碼示例

本文整理匯總了Python中pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header方法的典型用法代碼示例。如果您正苦於以下問題:Python ProcessEndpointUnitMixin._build_header方法的具體用法?Python ProcessEndpointUnitMixin._build_header怎麽用?Python ProcessEndpointUnitMixin._build_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyon.ion.endpoint.ProcessEndpointUnitMixin的用法示例。


在下文中一共展示了ProcessEndpointUnitMixin._build_header方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test__build_header_no_context

# 需要導入模塊: from pyon.ion.endpoint import ProcessEndpointUnitMixin [as 別名]
# 或者: from pyon.ion.endpoint.ProcessEndpointUnitMixin import _build_header [as 別名]
    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)
開發者ID:daf,項目名稱:pyon,代碼行數:16,代碼來源:test_endpoint.py

示例2: test__build_header_service

# 需要導入模塊: from pyon.ion.endpoint import ProcessEndpointUnitMixin [as 別名]
# 或者: from pyon.ion.endpoint.ProcessEndpointUnitMixin import _build_header [as 別名]
    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)
開發者ID:daf,項目名稱:pyon,代碼行數:21,代碼來源:test_endpoint.py

示例3: test__build_header_with_context

# 需要導入模塊: from pyon.ion.endpoint import ProcessEndpointUnitMixin [as 別名]
# 或者: from pyon.ion.endpoint.ProcessEndpointUnitMixin import _build_header [as 別名]
    def test__build_header_with_context(self, mockgci):
        procmock = Mock()
        procmock.get_context.return_value={'ion-actor-id': sentinel.ion_actor_id,
                                           'ion-actor-roles': sentinel.ion_actor_roles,
                                           'ion-actor-tokens': sentinel.ion_actor_tokens,
                                           'expiry': sentinel.expiry,
                                           'origin-container-id': sentinel.container_id}

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

        self.assertIn('ion-actor-id', header)
        self.assertIn('ion-actor-roles', header)
        self.assertIn('ion-actor-tokens', header)
        self.assertIn('expiry', header)
        self.assertIn('origin-container-id', header)

        self.assertEquals(header['ion-actor-id'], sentinel.ion_actor_id)
        self.assertEquals(header['ion-actor-roles'], sentinel.ion_actor_roles)
        self.assertEquals(header['ion-actor-tokens'], sentinel.ion_actor_tokens)
        self.assertEquals(header['expiry'], sentinel.expiry)
        self.assertEquals(header['origin-container-id'], sentinel.container_id)
開發者ID:daf,項目名稱:pyon,代碼行數:25,代碼來源:test_endpoint.py


注:本文中的pyon.ion.endpoint.ProcessEndpointUnitMixin._build_header方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。