当前位置: 首页>>代码示例>>Python>>正文


Python BaseDataHandler._update_new_data_check_attachment方法代码示例

本文整理汇总了Python中ion.agents.data.handlers.base_data_handler.BaseDataHandler._update_new_data_check_attachment方法的典型用法代码示例。如果您正苦于以下问题:Python BaseDataHandler._update_new_data_check_attachment方法的具体用法?Python BaseDataHandler._update_new_data_check_attachment怎么用?Python BaseDataHandler._update_new_data_check_attachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ion.agents.data.handlers.base_data_handler.BaseDataHandler的用法示例。


在下文中一共展示了BaseDataHandler._update_new_data_check_attachment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestBaseDataHandlerUnit

# 需要导入模块: from ion.agents.data.handlers.base_data_handler import BaseDataHandler [as 别名]
# 或者: from ion.agents.data.handlers.base_data_handler.BaseDataHandler import _update_new_data_check_attachment [as 别名]

#.........这里部分代码省略.........
        attachment_1._id = "attachment_1"
        attachment_1.keywords = ["NewDataCheck"]
        attachment_1.content = "content"
        rr_cli.find_attachments.return_value = [attachment_1]

        ret = self._bdh._find_new_data_check_attachment(res_id="res_id")
        self.assertEqual(ret, "content")
        rr_cli.find_attachments.assert_called_once_with(resource_id="res_id", include_content=False, id_only=False)

    @patch("ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient")
    def test__find_new_data_check_attachment_no_newdatacheck(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = "attachment_1"
        attachment_1.keywords = ["not_found"]
        attachment_1.content = "content"
        rr_cli.find_attachments.return_value = [attachment_1]

        ret = self._bdh._find_new_data_check_attachment(res_id="res_id")
        self.assertEqual(ret, None)
        rr_cli.find_attachments.assert_called_once_with(resource_id="res_id", include_content=False, id_only=False)

    @patch("ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient")
    def test__find_new_data_check_attachment_raise_notfound(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        rr_cli.find_attachments.side_effect = NotFound

        with self.assertRaises(InstrumentException) as cm:
            self._bdh._find_new_data_check_attachment(res_id="not_found")

        rr_cli.find_attachments.assert_called_once_with(resource_id="not_found", include_content=False, id_only=False)

    @patch("ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient")
    def test__update_new_data_check_attachment(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = "attachment_1"
        attachment_1.keywords = ["NewDataCheck"]
        attachment_1.content = "content"

        attachment_2 = Mock()
        attachment_2._id = "attachment_2"
        attachment_2.keywords = ["NewDataCheck"]
        attachment_2.content = "new_content"
        rr_cli.find_attachments.return_value = [attachment_1]
        rr_cli.create_attachment.return_value = attachment_2._id

        self._bdh._update_new_data_check_attachment(res_id="res_id", new_content=attachment_2.content)
        rr_cli.find_attachments.assert_called_once_with(resource_id="res_id", include_content=False, id_only=False)
        rr_cli.delete_attachment.assert_called_once_with(attachment_1._id)
        self.assertTrue(rr_cli.create_attachment.called)

    @patch("ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient")
    def test__update_new_data_check_attachment_no_newdatacheck(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = "attachment_1"
        attachment_1.keywords = ["notfound"]
        attachment_1.content = "content"

        attachment_2 = Mock()
        attachment_2._id = "attachment_2"
        attachment_2.keywords = ["NewDataCheck"]
        attachment_2.content = "new_content"
        rr_cli.find_attachments.return_value = [attachment_1]
        rr_cli.create_attachment.return_value = attachment_2._id
开发者ID:pombredanne,项目名称:coi-services,代码行数:70,代码来源:test_base_data_handler.py

示例2: TestBaseDataHandlerUnit

# 需要导入模块: from ion.agents.data.handlers.base_data_handler import BaseDataHandler [as 别名]
# 或者: from ion.agents.data.handlers.base_data_handler.BaseDataHandler import _update_new_data_check_attachment [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(ret, 'content')
        rr_cli.find_attachments.assert_called_once_with(resource_id='res_id',
            include_content=True,
            id_only=False)

    @patch('ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient')
    def test__find_new_data_check_attachment_no_newdatacheck(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = 'attachment_1'
        attachment_1.keywords = ['not_found']
        attachment_1.content = 'content'
        rr_cli.find_attachments.return_value = [attachment_1]

        ret = self._bdh._find_new_data_check_attachment(res_id='res_id')
        self.assertEqual(ret, None)
        rr_cli.find_attachments.assert_called_once_with(resource_id='res_id',
            include_content=True,
            id_only=False)

    @patch('ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient')
    def test__find_new_data_check_attachment_raise_notfound(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        rr_cli.find_attachments.side_effect = NotFound

        with self.assertRaises(InstrumentException):
            self._bdh._find_new_data_check_attachment(res_id='not_found')

        rr_cli.find_attachments.assert_called_once_with(resource_id='not_found',
            include_content=True,
            id_only=False)

    @patch('ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient')
    def test__update_new_data_check_attachment(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = 'attachment_1'
        attachment_1.keywords = ['NewDataCheck']
        attachment_1.content = 'content'

        attachment_2 = Mock()
        attachment_2._id = 'attachment_2'
        attachment_2.keywords = ['NewDataCheck']
        attachment_2.content = 'new_content'
        rr_cli.find_attachments.return_value = [attachment_1]
        rr_cli.create_attachment.return_value = attachment_2._id

        self._bdh._update_new_data_check_attachment(res_id='res_id',
            new_content=attachment_2.content)
        rr_cli.find_attachments.assert_called_once_with(resource_id='res_id',
            include_content=False,
            id_only=False)
        rr_cli.delete_attachment.assert_called_once_with(attachment_1._id)
        self.assertTrue(rr_cli.create_attachment.called)

    @patch('ion.agents.data.handlers.base_data_handler.ResourceRegistryServiceClient')
    def test__update_new_data_check_attachment_no_newdatacheck(self, rr_cli_cls):
        rr_cli = rr_cli_cls.return_value
        attachment_1 = Mock()
        attachment_1._id = 'attachment_1'
        attachment_1.keywords = ['notfound']
        attachment_1.content = 'content'

        attachment_2 = Mock()
        attachment_2._id = 'attachment_2'
        attachment_2.keywords = ['NewDataCheck']
开发者ID:Bobfrat,项目名称:coi-services,代码行数:70,代码来源:test_base_data_handler.py


注:本文中的ion.agents.data.handlers.base_data_handler.BaseDataHandler._update_new_data_check_attachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。