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


Python ErrorInterface.get_dict方法代码示例

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


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

示例1: test_change_general_fields

# 需要导入模块: from job.configuration.interface.error_interface import ErrorInterface [as 别名]
# 或者: from job.configuration.interface.error_interface.ErrorInterface import get_dict [as 别名]
    def test_change_general_fields(self):
        '''Tests calling JobTypeManager.edit_job_type() with a change to some general fields'''

        name = 'my-job-type'
        version = '1.0'
        title = 'my title'
        priority = 12
        error_mapping = ErrorInterface({
            'version': '1.0',
            'exit_codes': {
                '-15': self.error.name,
            }
        })
        new_title = 'my new title'
        new_priority = 13
        new_error_mapping = ErrorInterface({
            'version': '1.0',
            'exit_codes': {
                '-16': self.error.name,
            }
        })
        new_is_paused = True
        trigger_rule = trigger_test_utils.create_trigger_rule(trigger_type=job_test_utils.MOCK_TYPE,
                                                              configuration=self.trigger_config.get_dict())
        job_type = JobType.objects.create_job_type(name, version, self.job_interface, trigger_rule, title=title,
                                                   priority=priority, error_mapping=error_mapping)

        # Call test
        JobType.objects.edit_job_type(job_type.id, title=new_title, priority=new_priority,
                                      error_mapping=new_error_mapping, is_paused=new_is_paused)

        # Check results
        job_type = JobType.objects.select_related('trigger_rule').get(pk=job_type.id)
        self.assertDictEqual(job_type.get_job_interface().get_dict(), self.job_interface.get_dict())
        self.assertEqual(job_type.revision_num, 1)
        self.assertEqual(job_type.trigger_rule_id, trigger_rule.id)
        trigger_rule = TriggerRule.objects.get(pk=trigger_rule.id)
        self.assertTrue(trigger_rule.is_active)
        self.assertEqual(job_type.title, new_title)
        self.assertEqual(job_type.priority, new_priority)
        self.assertDictEqual(job_type.get_error_interface().get_dict(), new_error_mapping.get_dict())
        self.assertEqual(job_type.is_paused, new_is_paused)
        self.assertIsNotNone(job_type.paused)
开发者ID:cshamis,项目名称:scale,代码行数:45,代码来源:test_models.py

示例2: TestJobTypeManagerCreateJobType

# 需要导入模块: from job.configuration.interface.error_interface import ErrorInterface [as 别名]
# 或者: from job.configuration.interface.error_interface.ErrorInterface import get_dict [as 别名]
class TestJobTypeManagerCreateJobType(TransactionTestCase):

    def setUp(self):
        django.setup()

        self.workspace = storage_test_utils.create_workspace()
        self.error = error_test_utils.create_error()

        interface = {
            'version': '1.0',
            'command': 'my_command',
            'command_arguments': 'args',
            'input_data': [{
                'name': 'Test Input 1',
                'type': 'file',
                'media_types': ['text/plain'],
            }],
            'output_data': [{
                'name': 'Test Output 1',
                'type': 'files',
                'media_type': 'image/png',
            }]}
        self.job_interface = JobInterface(interface)

        self.configuration = {
            'version': '1.0',
            'condition': {
                'media_type': 'text/plain'
            },
            'data': {
                'input_data_name': 'Test Input 1',
                'workspace_name': self.workspace.name
            }
        }
        self.trigger_config = job_test_utils.MockTriggerRuleConfiguration(job_test_utils.MOCK_TYPE, self.configuration)

        self.error_mapping = ErrorInterface({
            'version': '1.0',
            'exit_codes': {
                '-15': self.error.name,
            }
        })

    def test_successful_no_trigger_rule(self):
        '''Tests calling JobTypeManager.create_job_type() successfully with no trigger rule or error mapping'''

        name = 'my-job-type'
        version = '1.0'

        # Call test
        job_type = JobType.objects.create_job_type(name, version, self.job_interface)

        # Check results
        job_type = JobType.objects.select_related('trigger_rule').get(pk=job_type.id)
        self.assertDictEqual(job_type.get_job_interface().get_dict(), self.job_interface.get_dict())
        self.assertEqual(job_type.revision_num, 1)
        self.assertIsNone(job_type.trigger_rule_id)
        self.assertDictEqual(job_type.get_error_interface().get_dict(), ErrorInterface(None).get_dict())

    def test_successful_with_trigger_rule(self):
        '''Tests calling JobTypeManager.create_job_type() successfully with a trigger rule and error mapping'''

        name = 'my-job-type'
        version = '1.0'
        trigger_rule = trigger_test_utils.create_trigger_rule(trigger_type=job_test_utils.MOCK_TYPE,
                                                              configuration=self.trigger_config.get_dict())

        # Call test
        job_type = JobType.objects.create_job_type(name, version, self.job_interface, trigger_rule, self.error_mapping)

        # Check results
        job_type = JobType.objects.select_related('trigger_rule').get(pk=job_type.id)
        self.assertDictEqual(job_type.get_job_interface().get_dict(), self.job_interface.get_dict())
        self.assertEqual(job_type.revision_num, 1)
        self.assertEqual(job_type.trigger_rule_id, trigger_rule.id)
        trigger_rule = TriggerRule.objects.get(pk=trigger_rule.id)
        self.assertTrue(trigger_rule.is_active)
        self.assertDictEqual(job_type.get_error_interface().get_dict(), self.error_mapping.get_dict())

    def test_invalid_trigger_rule(self):
        '''Tests calling JobTypeManager.create_job_type() with an invalid trigger rule'''

        name = 'my-job-type'
        version = '1.0'
        trigger_rule = trigger_test_utils.create_trigger_rule(trigger_type=job_test_utils.MOCK_ERROR_TYPE,
                                                              configuration=self.trigger_config.get_dict())

        # Call test
        self.assertRaises(InvalidConnection, JobType.objects.create_job_type, name, version, self.job_interface,
                          trigger_rule, self.error_mapping)

    def test_successful_other_fields(self):
        '''Tests calling JobTypeManager.create_job_type() successfully with additional fields'''

        name = 'my-job-type'
        version = '1.0'
        title = 'my title'
        description = 'my-description'
        priority = 13

#.........这里部分代码省略.........
开发者ID:cshamis,项目名称:scale,代码行数:103,代码来源:test_models.py


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