本文整理汇总了Python中lava_scheduler_app.models.DeviceDictionary.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceDictionary.to_dict方法的具体用法?Python DeviceDictionary.to_dict怎么用?Python DeviceDictionary.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lava_scheduler_app.models.DeviceDictionary
的用法示例。
在下文中一共展示了DeviceDictionary.to_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exclusivity
# 需要导入模块: from lava_scheduler_app.models import DeviceDictionary [as 别名]
# 或者: from lava_scheduler_app.models.DeviceDictionary import to_dict [as 别名]
def test_exclusivity(self):
device = Device.objects.get(hostname="fakeqemu1")
self.assertTrue(device.is_pipeline)
self.assertFalse(device.is_exclusive)
self.assertIsNotNone(DeviceDictionary.get(device.hostname))
device_dict = DeviceDictionary(hostname=device.hostname)
device_dict.save()
device_dict = DeviceDictionary.get(device.hostname)
self.assertTrue(device.is_pipeline)
self.assertFalse(device.is_exclusive)
update = device_dict.to_dict()
update.update({'exclusive': 'True'})
device_dict.parameters = update
device_dict.save()
self.assertTrue(device.is_pipeline)
self.assertTrue(device.is_exclusive)
示例2: test_identify_context
# 需要导入模块: from lava_scheduler_app.models import DeviceDictionary [as 别名]
# 或者: from lava_scheduler_app.models.DeviceDictionary import to_dict [as 别名]
def test_identify_context(self):
hostname = "fakebbb"
mustang_type = self.factory.make_device_type('beaglebone-black')
# this sets a qemu device dictionary, so replace it
self.factory.make_device(device_type=mustang_type, hostname=hostname)
mustang = DeviceDictionary(hostname=hostname)
mustang.parameters = {
'extends': 'beaglebone-black.jinja2',
'base_nfsroot_args': '10.16.56.2:/home/lava/debian/nfs/,tcp,hard,intr',
'console_device': 'ttyO0', # takes precedence over the job context as the same var name is used.
}
mustang.save()
mustang_dict = mustang.to_dict()
device = Device.objects.get(hostname="fakebbb")
self.assertEqual('beaglebone-black', device.device_type.name)
self.assertTrue(device.is_pipeline)
context_overrides = map_context_overrides('base.jinja2', 'beaglebone-black.jinja2', system=False)
job_ctx = {
'base_uboot_commands': 'dummy commands',
'usb_uuid': 'dummy usb uuid',
'console_device': 'ttyAMA0',
'usb_device_id': 1111111111111111
}
device_config = device.load_device_configuration(job_ctx, system=False) # raw dict
self.assertIsNotNone(device_config)
devicetype_blocks = []
devicedict_blocks = []
allowed = []
for key, _ in job_ctx.items():
if key in context_overrides:
if key is not 'extends' and key not in mustang_dict['parameters'].keys():
allowed.append(key)
else:
devicedict_blocks.append(key)
else:
devicetype_blocks.append(key)
# only values set in job_ctx are checked
self.assertEqual(set(allowed), {'usb_device_id', 'usb_uuid'})
self.assertEqual(set(devicedict_blocks), {'console_device'})
self.assertEqual(set(devicetype_blocks), {'base_uboot_commands'})
full_list = allowed_overrides(mustang_dict, system=False)
for key in allowed:
self.assertIn(key, full_list)