本文整理汇总了Python中pyon.util.containers.DotDict.update_widget方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.update_widget方法的具体用法?Python DotDict.update_widget怎么用?Python DotDict.update_widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.util.containers.DotDict
的用法示例。
在下文中一共展示了DotDict.update_widget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generic_fcruf_script
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update_widget [as 别名]
def generic_fcruf_script(self, resource_iontype, resource_label, owner_service, is_simple, actual_obj=None):
"""
run through find, create, read, update, and find ops on a basic resource
NO DELETE in here.
@param resource_iontype something like RT.BlahBlar
@param resource_label something like platform_model
@param owner_service a service client instance
@param is_simple whether to check for AVAILABLE LCS on create
"""
# this section is just to make the LCA integration script easier to write.
#
# each resource type gets put through (essentially) the same steps.
#
# so, we just set up a generic service-esque object.
# (basically just a nice package of shortcuts):
# create a fake service object and populate it with the methods we need
some_service = DotDict()
def fill(svc, method):
"""
make a "shortcut service" for testing crud ops.
@param svc a dotdict
@param method the method name to add
"""
realmethod = "%s_widget" % method
setattr(svc, realmethod,
getattr(owner_service, "%s_%s" % (method, resource_label)))
fill(some_service, "create")
fill(some_service, "read")
fill(some_service, "update")
fill(some_service, "delete")
def find_widgets():
ret, _ = self.client.RR.find_resources(resource_iontype, None, None, False)
return ret
#UX team: generic script for LCA resource operations begins here.
# some_service will be replaced with whatever service you're calling
# widget will be replaced with whatever resource you're working with
# resource_label will be data_product or logical_instrument
log.info("Finding %s objects", resource_label)
num_objs = len(find_widgets())
log.info("I found %d %s objects", num_objs, resource_label)
generic_obj = actual_obj or any_old(resource_iontype)
log.info("Creating a %s with name='%s'", resource_label, generic_obj.name)
generic_id = some_service.create_widget(generic_obj)
self.assertIsNotNone(generic_id, "%s failed its creation" % resource_iontype)
log.info("Reading %s '%s'", resource_label, generic_id)
generic_ret = some_service.read_widget(generic_id)
log.info("Verifying equality of stored and retrieved object")
self.assertEqual(generic_obj.name, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
#"simple" resources go available immediately upon creation, so check:
if is_simple:
log.info("Verifying that resource went DEPLOYED_AVAILABLE on creation")
self.assertEqual(generic_ret.lcstate, LCS.DEPLOYED_AVAILABLE)
log.info("Updating %s '%s'", resource_label, generic_id)
generic_newname = "%s updated" % generic_ret.name
generic_ret.name = generic_newname
some_service.update_widget(generic_ret)
log.info("Reading %s '%s' to verify update", resource_iontype, generic_id)
generic_ret = some_service.read_widget(generic_id)
self.assertEqual(generic_newname, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
log.info("Finding %s objects... checking that there's a new one", resource_iontype)
num_objs2 = len(find_widgets())
log.info("There were %s and now there are %s", num_objs, num_objs2)
self.assertTrue(num_objs2 > num_objs)
log.info("Returning %s with id '%s'", resource_iontype, generic_id)
return generic_id
示例2: generic_fcruf_script
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update_widget [as 别名]
def generic_fcruf_script(self, resource_iontype, resource_label, owner_service, is_simple):
"""
run through find, create, read, update, and find ops on a basic resource
NO DELETE in here.
@param resource_iontype something like RT.BlahBlar
@param resource_label something like platform_model
@param owner_service a service client instance
@param is_simple whether to check for AVAILABLE LCS on create
"""
# this section is just to make the LCA integration script easier to write.
#
# each resource type gets put through (essentially) the same steps.
#
# so, we just set up a generic service-esque object.
# (basically just a nice package of shortcuts):
# create a fake service object and populate it with the methods we need
some_service = DotDict()
def make_plural(noun):
if "y" == noun[-1]:
return noun[:-1] + "ies"
else:
return noun + "s"
def fill(svc, method, plural=False):
"""
make a "shortcut service" for testing crud ops.
@param svc a dotdict
@param method the method name to add
@param plural whether to make the resource label plural
"""
reallabel = resource_label
realmethod = "%s_widget" % method
if plural:
reallabel = make_plural(reallabel)
realmethod = realmethod + "s"
setattr(svc, realmethod,
getattr(owner_service, "%s_%s" % (method, reallabel)))
fill(some_service, "create")
fill(some_service, "read")
fill(some_service, "update")
fill(some_service, "delete")
fill(some_service, "find", True)
#UX team: generic script for LCA resource operations begins here.
# some_service will be replaced with whatever service you're calling
# widget will be replaced with whatever resource you're working with
# resource_label will be data_product or logical_instrument
resource_labels = make_plural(resource_label)
log.info("Finding %s" % resource_labels)
num_objs = len(some_service.find_widgets())
log.info("I found %d %s" % (num_objs, resource_labels))
log.info("Creating a %s" % resource_label)
generic_obj = any_old(resource_iontype)
generic_id = some_service.create_widget(generic_obj)
log.info("Reading %s #%s" % (resource_label, generic_id))
generic_ret = some_service.read_widget(generic_id)
log.info("Verifying equality of stored and retrieved object")
self.assertEqual(generic_obj.name, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
#"simple" resources go available immediately upon creation, so check:
if is_simple:
log.info("Verifying that resource went DEPLOYED_AVAILABLE on creation")
self.assertEqual(generic_ret.lcstate, LCS.DEPLOYED_AVAILABLE)
log.info("Updating %s #%s" % (resource_label, generic_id))
generic_newname = "%s updated" % generic_ret.name
generic_ret.name = generic_newname
some_service.update_widget(generic_ret)
log.info("Reading platform model #%s to verify update" % generic_id)
generic_ret = some_service.read_widget(generic_id)
self.assertEqual(generic_newname, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
log.info("Finding platform models... checking that there's a new one")
num_objs2 = len(some_service.find_widgets())
self.assertTrue(num_objs2 > num_objs)
#.........这里部分代码省略.........
示例3: perform_fcruf_script
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update_widget [as 别名]
def perform_fcruf_script(self, resource_iontype, resource_label, owner_service, actual_obj=None, extra_fn=None):
"""
run through find, create, read, update, and find ops on a basic resource
NO DELETE in here.
@param resource_iontype something like RT.PlatformModel
@param resource_label something like platform_model
@param owner_service a service client instance like InstrumentManagementServiceClient
@param actual_obj use this IonObject instead of a generic object for testing
@param extra_fn a function to run after the script, taking the new resource id as input
@return generic_id, the resource_id of the generic resource that was created
"""
# this section is just to make the LCA integration script easier to write.
#
# each resource type gets put through (essentially) the same steps.
#
# so, we just set up a generic service-esque object.
# (basically just a nice package of shortcuts):
# create a fake service object and populate it with the methods we need
some_service = DotDict()
def fill(svc, method):
"""
make a "shortcut service" for testing crud ops.
@param svc a dotdict
@param method the method name to add
"""
realmethod = "%s_widget" % method
setattr(svc, realmethod,
getattr(owner_service, "%s_%s" % (method, resource_label)))
fill(some_service, "create")
fill(some_service, "read")
fill(some_service, "update")
fill(some_service, "delete")
def find_widgets():
ret, _ = self.generic_int_helper_rr.find_resources(resource_iontype, None, None, False)
return ret
#UX team: generic script for LCA resource operations begins here.
# some_service will be replaced with whatever service you're calling
# widget will be replaced with whatever resource you're working with
# resource_label will be data_product or logical_instrument
log.info("Finding %s objects", resource_label)
num_objs = len(find_widgets())
log.info("I found %d %s objects", num_objs, resource_label)
generic_obj = actual_obj or any_old(resource_iontype)
log.info("Creating a %s with name='%s'", resource_label, generic_obj.name)
generic_id = some_service.create_widget(generic_obj)
self.assertIsNotNone(generic_id, "%s failed its creation" % resource_iontype)
log.info("Reading %s '%s'", resource_label, generic_id)
generic_ret = some_service.read_widget(generic_id)
log.info("Verifying equality of stored and retrieved object")
self.assertEqual(generic_obj.name, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
log.info("Updating %s '%s'", resource_label, generic_id)
generic_newname = "%s updated" % generic_ret.name
generic_ret.name = generic_newname
some_service.update_widget(generic_ret)
log.info("Reading %s '%s' to verify update", resource_iontype, generic_id)
generic_ret = some_service.read_widget(generic_id)
self.assertEqual(generic_newname, generic_ret.name)
self.assertEqual(generic_obj.description, generic_ret.description)
log.info("Finding %s objects... checking that there's a new one", resource_iontype)
num_objs2 = len(find_widgets())
log.info("There were %s and now there are %s", num_objs, num_objs2)
self.assertTrue(num_objs2 > num_objs)
if not extra_fn is None:
log.info("Running extra_fn on generic resource '%s'" % generic_id)
extra_fn(generic_id)
log.info("Returning %s with id '%s'", resource_iontype, generic_id)
return generic_id