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


Python TestJob.from_json_and_user方法代码示例

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


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

示例1: test_from_json_and_user_reuses_tag_objects

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_reuses_tag_objects(self):
     device_type = self.factory.ensure_device_type(name='panda')
     self.factory.ensure_tag('tag')
     tags = list(Tag.objects.filter(name='tag'))
     self.factory.make_device(device_type=device_type, hostname="panda3", tags=tags)
     job1 = TestJob.from_json_and_user(
         self.factory.make_job_json(tags=['tag']),
         self.factory.make_user())
     job2 = TestJob.from_json_and_user(
         self.factory.make_job_json(tags=['tag']),
         self.factory.make_user())
     self.assertEqual(
         set(tag.pk for tag in job1.tags.all()),
         set(tag.pk for tag in job2.tags.all()))
开发者ID:OSSystems,项目名称:lava-server,代码行数:16,代码来源:submission.py

示例2: test_from_json_and_user_does_not_set_device_type_from_target

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_does_not_set_device_type_from_target(self):
     panda_type = self.factory.ensure_device_type(name='panda')
     self.factory.make_device(device_type=panda_type, hostname='panda01')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(target='panda01'),
         self.factory.make_user())
     self.assertEqual(None, job.requested_device_type)
开发者ID:OSSystems,项目名称:lava-server,代码行数:9,代码来源:submission.py

示例3: test_from_json_and_user_repeat_parameter_zero

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_repeat_parameter_zero(self):
     device_type = self.factory.make_device_type('base')
     device = self.factory.make_device(device_type=device_type, hostname="generic")
     repeat = 0
     job_data = {
         'timeout': 1,
         'target': device.hostname,
         'actions': [
             {
                 'command': 'lava_test_shell',
                 'parameters': {
                     'repeat': repeat,
                     'testdef_repos': [
                         {
                             'git-repo': 'git://server/test.git',
                             'testdef': 'testdef.yaml'
                         }
                     ],
                 }
             }
         ],
     }
     job_json = simplejson.dumps(job_data, sort_keys=True, indent=4 * ' ')
     job = TestJob.from_json_and_user(job_json, self.factory.make_user())
     definition_data = simplejson.loads(job.definition)
     self.assertEqual(len(definition_data['actions']), 1)
     self.assertNotIn('repeat_count', definition_data['actions'][0]['parameters'])
     self.assertNotIn('repeat', definition_data['actions'][0]['parameters'])
     self.assertEqual(job.status, TestJob.SUBMITTED)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:32,代码来源:test_submission.py

示例4: test_from_json_and_user_sets_target

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_target(self):
     panda_board = self.factory.make_device(hostname='panda01')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(target='panda01'),
         self.factory.make_user())
     self.assertEqual(panda_board, job.requested_device)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:9,代码来源:test_submission.py

示例5: test_from_json_and_user_sets_device_type

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_device_type(self):
     panda_type = self.factory.ensure_device_type(name='panda')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(device_type='panda'),
         self.factory.make_user())
     self.assertEqual(panda_type, job.requested_device_type)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:9,代码来源:test_submission.py

示例6: test_from_json_and_user_sets_date_submitted

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_date_submitted(self):
     before = datetime.datetime.now()
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(),
         self.factory.make_user())
     after = datetime.datetime.now()
     self.assertTrue(before < job.submit_time < after)
开发者ID:OSSystems,项目名称:lava-server,代码行数:9,代码来源:submission.py

示例7: test_from_json_and_user_errors_on_unsupported_tags

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_errors_on_unsupported_tags(self):
     """
     Tests that tags which do exist but are not defined for the
     any of the devices of the requested type cause the submission
     to be rejected with Devices Unavailable.
     """
     device_type = self.factory.ensure_device_type(name='panda')
     self.factory.make_device(device_type=device_type, hostname="panda2")
     self.factory.ensure_tag('tag1')
     self.factory.ensure_tag('tag2')
     try:
         TestJob.from_json_and_user(
             self.factory.make_job_json(tags=['tag1', 'tag2']),
             self.factory.make_user())
     except DevicesUnavailableException:
         pass
     else:
         self.fail("Device tags failure: job submitted without any devices supporting the requested tags")
开发者ID:OSSystems,项目名称:lava-server,代码行数:20,代码来源:submission.py

示例8: make_testjob

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def make_testjob(self, definition=None, submitter=None, **kwargs):
     if definition is None:
         definition = self.make_job_json()
     if submitter is None:
         submitter = self.make_user()
     if 'user' not in kwargs:
         kwargs['user'] = submitter
     testjob = TestJob.from_json_and_user(definition, submitter)
     testjob.save()
     return testjob
开发者ID:OSSystems,项目名称:lava-server,代码行数:12,代码来源:submission.py

示例9: test_from_json_and_user_can_submit_to_anonymous

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_can_submit_to_anonymous(self):
     user = self.factory.make_user()
     anon_user = User.objects.get_or_create(username="anonymous-owner")[0]
     b = BundleStream.objects.create(
         slug='anonymous', is_anonymous=True, user=anon_user,
         is_public=True)
     b.save()
     j = self.make_job_json_for_stream_name('/anonymous/anonymous/')
     job = TestJob.from_json_and_user(j, user)
     self.assertEqual(user, job.submitter)
开发者ID:OSSystems,项目名称:lava-server,代码行数:12,代码来源:submission.py

示例10: test_from_json_and_user_sets_is_public_from_bundlestream

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_is_public_from_bundlestream(self):
     group = Group.objects.create(name='group')
     user = self.factory.make_user()
     user.groups.add(group)
     b = BundleStream.objects.create(
         group=group, slug='blah', is_public=False, is_anonymous=False)
     b.save()
     j = self.make_job_json_for_stream_name(b.pathname)
     job = TestJob.from_json_and_user(j, user)
     self.assertEqual(False, job.is_public)
开发者ID:OSSystems,项目名称:lava-server,代码行数:12,代码来源:submission.py

示例11: testjob_submission

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
def testjob_submission(job_definition, user, check_device=None):
    """
    Single submission frontend for JSON or YAML
    :param job_definition: string of the job submission
    :param user: user attempting the submission
    :param check_device: set specified device as the target
    **and** thereby set job as a health check job. (JSON only)
    :return: a job or a list of jobs
    :raises: SubmissionException, Device.DoesNotExist,
        DeviceType.DoesNotExist, DevicesUnavailableException,
        JSONDataError, JSONDecodeError, ValueError
    """

    if is_deprecated_json(job_definition):
        allow_health = False
        job_json = simplejson.loads(job_definition)
        target_device = None
        if 'target' in job_json:
            target_device = Device.objects.get(hostname=job_json['target'])
        if check_device:
            job_json['target'] = check_device.hostname
            job_json['health-check'] = True
            job_definition = simplejson.dumps(job_json)
            allow_health = True
        try:
            # returns a single job or a list (not a QuerySet) of job objects.
            job = TestJob.from_json_and_user(job_definition, user, health_check=allow_health)
            if isinstance(job, list):
                # multinode health checks not supported
                return job
            job.health_check = allow_health
            if check_device:
                job.requested_device = check_device
            elif target_device:
                job.requested_device = target_device
            job.save(update_fields=['health_check', 'requested_device'])
        except (JSONDataError, ValueError) as exc:
            if check_device:
                check_device.put_into_maintenance_mode(
                    user, "Job submission failed for health job for %s: %s" % (check_device, exc))
                raise JSONDataError("Health check job submission failed for %s: %s" % (check_device, exc))
            else:
                raise JSONDataError("Job submission failed: %s" % exc)

    else:
        validate_job(job_definition)
        # returns a single job or a list (not a QuerySet) of job objects.
        job = TestJob.from_yaml_and_user(job_definition, user)
        if check_device and isinstance(check_device, Device) and not isinstance(job, list):
            # the slave must neither know nor care if this is a health check,
            # only the master cares and that has the database connection.
            job.health_check = True
            job.requested_device = check_device
            job.save(update_fields=['health_check', 'requested_device'])
    return job
开发者ID:dl9pf,项目名称:lava-server,代码行数:57,代码来源:dbutils.py

示例12: test_from_json_and_user_sets_tag_from_device_tags

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_tag_from_device_tags(self):
     device_type = self.factory.ensure_device_type(name='panda')
     self.factory.ensure_tag('tag')
     tags = list(Tag.objects.filter(name='tag'))
     self.factory.make_device(device_type=device_type, hostname="panda1", tags=tags)
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(tags=['tag']),
         self.factory.make_user())
     self.assertEqual(
         set(tag.name for tag in job.tags.all()), {'tag'})
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:13,代码来源:test_submission.py

示例13: test_from_json_and_user_sets_multiple_tag_from_device_tags

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_sets_multiple_tag_from_device_tags(self):
     device_type = self.factory.ensure_device_type(name='panda')
     tag_list = [
         self.factory.ensure_tag('tag1'),
         self.factory.ensure_tag('tag2')
     ]
     self.factory.make_device(device_type=device_type, hostname="panda2", tags=tag_list)
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(tags=['tag1', 'tag2']),
         self.factory.make_user())
     self.assertEqual(
         set(tag.name for tag in job.tags.all()), {'tag1', 'tag2'})
开发者ID:OSSystems,项目名称:lava-server,代码行数:14,代码来源:submission.py

示例14: submit_job

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
    def submit_job(self, job_data):
        """
        Name
        ----
        `submit_job` (`job_data`)

        Description
        -----------
        Submit the given job data which is in LAVA job JSON format as a new
        job to LAVA scheduler.

        Arguments
        ---------
        `job_data`: string
            Job JSON string.

        Return value
        ------------
        This function returns an XML-RPC integer which is the newly created
        job's id,  provided the user is authenticated with an username and
        token.
        """
        if not self.user:
            raise xmlrpclib.Fault(
                401, "Authentication with user and token required for this "
                "API.")
        if not self.user.has_perm('lava_scheduler_app.add_testjob'):
            raise xmlrpclib.Fault(
                403, "Permission denied.  User %r does not have the "
                "'lava_scheduler_app.add_testjob' permission.  Contact "
                "the administrators." % self.user.username)
        try:
            job = TestJob.from_json_and_user(job_data, self.user)
        except JSONDecodeError as e:
            raise xmlrpclib.Fault(400, "Decoding JSON failed: %s." % e)
        except (JSONDataError, ValueError) as e:
            raise xmlrpclib.Fault(400, str(e))
        except Device.DoesNotExist:
            raise xmlrpclib.Fault(404, "Specified device not found.")
        except DeviceType.DoesNotExist:
            raise xmlrpclib.Fault(404, "Specified device type not found.")
        except DevicesUnavailableException as e:
            raise xmlrpclib.Fault(400, str(e))
        if isinstance(job, type(list())):
            return [j.sub_id for j in job]
        else:
            return job.id
开发者ID:OSSystems,项目名称:lava-server,代码行数:49,代码来源:api.py

示例15: test_from_json_and_user_can_submit_to_group_stream

# 需要导入模块: from lava_scheduler_app.models import TestJob [as 别名]
# 或者: from lava_scheduler_app.models.TestJob import from_json_and_user [as 别名]
 def test_from_json_and_user_can_submit_to_group_stream(self):
     user = self.factory.make_user()
     anon_user = User.objects.get_or_create(username="anonymous-owner")[0]
     group = Group.objects.get_or_create(name="owner")[0]
     group.user_set.add(user)
     b = BundleStream.objects.create(
         slug='basic',
         is_anonymous=False,
         group=group,
         is_public=True)
     b.save()
     self.assertEqual(b.pathname, "/public/team/owner/basic/")
     j = self.make_job_json_for_stream_name(b.pathname)
     job = TestJob.from_json_and_user(j, user)
     self.assertEqual(user, job.submitter)
     self.assertEqual(True, job.is_public)
     self.assertRaises(ValueError, TestJob.from_json_and_user, j, anon_user)
开发者ID:SivagnanamCiena,项目名称:lava-server,代码行数:19,代码来源:test_submission.py


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