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


Python JobDefinition.get_checksum方法代码示例

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


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

示例1: test_via_does_not_change_checksum

# 需要导入模块: from plainbox.impl.job import JobDefinition [as 别名]
# 或者: from plainbox.impl.job.JobDefinition import get_checksum [as 别名]
 def test_via_does_not_change_checksum(self):
     parent = JobDefinition({'name': 'parent', 'plugin': 'local'})
     child = parent.create_child_job_from_record(
         RFC822Record({'name': 'test', 'plugin': 'shell'}, None))
     helper = JobDefinition({'name': 'test', 'plugin': 'shell'})
     self.assertEqual(child.via, parent.get_checksum())
     self.assertEqual(child.get_checksum(), helper.get_checksum())
开发者ID:jeffmarcom,项目名称:checkbox,代码行数:9,代码来源:test_job.py

示例2: test_checksum_smoke

# 需要导入模块: from plainbox.impl.job import JobDefinition [as 别名]
# 或者: from plainbox.impl.job.JobDefinition import get_checksum [as 别名]
 def test_checksum_smoke(self):
     job1 = JobDefinition({"name": "name", "plugin": "plugin"})
     identical_to_job1 = JobDefinition({"name": "name", "plugin": "plugin"})
     # Two distinct but identical jobs have the same checksum
     self.assertEqual(job1.get_checksum(), identical_to_job1.get_checksum())
     job2 = JobDefinition({"name": "other name", "plugin": "plugin"})
     # Two jobs with different definitions have different checksum
     self.assertNotEqual(job1.get_checksum(), job2.get_checksum())
     # The checksum is stable and does not change over time
     self.assertEqual(job1.get_checksum(), "ad137ba3654827cb07a254a55c5e2a8daa4de6af604e84ccdbe9b7f221014362")
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:12,代码来源:test_job.py

示例3: GeneratedJobSuspendTests

# 需要导入模块: from plainbox.impl.job import JobDefinition [as 别名]
# 或者: from plainbox.impl.job.JobDefinition import get_checksum [as 别名]
class GeneratedJobSuspendTests(TestCase):
    """
    Tests that check how SessionSuspendHelper behaves when faced with
    generated jobs. This tests sets up the following job hierarchy:

        __category__
           \-> generator
                \-> generated

    The "__category__" job is a typical "catter" job that cats an existing
    job from somewhere else in the filesystem. This type of generated job
    is used often for category assignment.

    The "generator" job is a typical non-catter job that actually creates
    new jobs in some way. In this test it generates a job called "generated".
    """

    def setUp(self):
        # Crete a "__category__" job
        self.category_job = JobDefinition({
            "plugin": "local",
            "name": "__category__"
        })
        # Create a "generator" job
        self.generator_job = JobDefinition({
            "plugin": "local",
            "name": "generator"
        })
        # Keep a variable for the (future) generated job
        self.generated_job = None
        # Create a result for the "__category__" job.
        # It must define a verbatim copy of the "generator" job
        self.category_result = MemoryJobResult({
            "io_log": [
                (0.0, "stdout", b'plugin:local\n'),
                (0.1, "stdout", b'name:generator\n'),
            ]
        })
        # Create a result for the "generator" job.
        # It will define the "generated" job
        self.generator_result = MemoryJobResult({
            "io_log": [(0.0, 'stdout', b'name:generated')]
        })
        # Create a session that knows about the two jobs that exist
        # directly as files (__category__ and generator)
        self.session_state = SessionState([
            self.category_job, self.generator_job])
        # Select both of them for execution.
        self.session_state.update_desired_job_list([
            self.category_job, self.generator_job])
        # "execute" the "__category__" job by showing the session the result
        self.session_state.update_job_result(
            self.category_job, self.category_result)
        # Ensure that the generator job gained the "via" attribute
        # This is how we know the code above has no typos or anything.
        self.assertEqual(
            self.generator_job.via, self.category_job.get_checksum())
        # "execute" the "generator" job by showing the session the result.
        # Connect the 'on_job_added' signal to a helper function that
        # extracts the "generated" job

        def job_added(self, job):
            self.generated_job = job
        # Use partial to supply 'self' from the class into the function above
        self.session_state.on_job_added.connect(partial(job_added, self))
        # Show the result of the "generator" job to the session,
        # this will define the "generated" job, fire the signal
        # and call our callback
        self.session_state.update_job_result(
            self.generator_job, self.generator_result)
        # Ensure that we got the generated_job variable assigned
        # (by the event/signal handled above)
        self.assertIsNot(self.generated_job, None)
        # Now the stage is set for testing. Let's create the suspend helper
        # and use the data we've defined so far to create JSON-friendly
        # description of the session state.
        self.helper = SessionSuspendHelper()
        self.data = self.helper._repr_SessionState(self.session_state)

    def test_state_tracked_for_all_jobs(self):
        """
        verify that 'state' keeps track of all three jobs
        """
        self.assertIn(self.category_job.name, self.data['jobs'])
        self.assertIn(self.generator_job.name, self.data['jobs'])
        self.assertIn(self.generated_job.name, self.data['jobs'])

    def test_category_job_result_is_saved(self):
        """
        verify that the 'category' job result was saved
        """
        # This result is essential to re-create the association
        # with the 'generator' job. In theory we could get it from
        # the 'via' attribute but that is only true for category assignment
        # where the child job already exists and is defined on the
        # filesystem. This would not work in the case of truly generated jobs
        # so for consistency it is done the same way.
        self.assertEqual(
            self.data['results']['__category__'], [{
                'comments': None,
#.........这里部分代码省略.........
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:103,代码来源:test_suspend.py

示例4: test_via_does_not_change_checksum

# 需要导入模块: from plainbox.impl.job import JobDefinition [as 别名]
# 或者: from plainbox.impl.job.JobDefinition import get_checksum [as 别名]
 def test_via_does_not_change_checksum(self):
     parent = JobDefinition({"name": "parent", "plugin": "local"})
     child = parent.create_child_job_from_record(RFC822Record({"name": "test", "plugin": "shell"}, None))
     helper = JobDefinition({"name": "test", "plugin": "shell"})
     self.assertEqual(child.via, parent.get_checksum())
     self.assertEqual(child.get_checksum(), helper.get_checksum())
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:8,代码来源:test_job.py


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