本文整理汇总了Python中shinysdr.values.CollectionState.state_from_json方法的典型用法代码示例。如果您正苦于以下问题:Python CollectionState.state_from_json方法的具体用法?Python CollectionState.state_from_json怎么用?Python CollectionState.state_from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shinysdr.values.CollectionState
的用法示例。
在下文中一共展示了CollectionState.state_from_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestStateInsert
# 需要导入模块: from shinysdr.values import CollectionState [as 别名]
# 或者: from shinysdr.values.CollectionState import state_from_json [as 别名]
class TestStateInsert(unittest.TestCase):
object = None
def test_success(self):
self.object = InsertFailSpecimen()
self.object.state_from_json({'foo': {'fail': False}})
self.assertEqual(['foo'], self.object.state().keys())
def test_failure(self):
self.object = InsertFailSpecimen()
self.object.state_from_json({'foo': {'fail': True}})
# throws but exception is caught
self.assertEqual([], self.object.state().keys())
def test_undefined(self):
'''no state_insert method defined'''
self.object = CollectionState({}, dynamic=True)
self.object.state_from_json({'foo': {'fail': True}})
# throws but exception is caught
self.assertEqual([], self.object.state().keys())
示例2: TestStateInsert
# 需要导入模块: from shinysdr.values import CollectionState [as 别名]
# 或者: from shinysdr.values.CollectionState import state_from_json [as 别名]
class TestStateInsert(unittest.TestCase):
object = None
def test_success(self):
self.object = InsertFailSpecimen()
self.object.state_from_json({'foo': {'fail': False}})
self.assertEqual(['foo'], list(self.object.state().keys()))
def test_failure(self):
self.object = InsertFailSpecimen()
self.object.state_from_json({'foo': {'fail': True}})
# throws but exception is caught -- TODO: Test logging
self.assertEqual([], list(self.object.state().keys()))
self.flushLoggedErrors(ValueError)
def test_undefined(self):
"""no state_insert method defined"""
self.object = CollectionState(CellDict(dynamic=True))
self.object.state_from_json({'foo': {'fail': True}})
# throws but exception is caught -- TODO: Test logging
self.assertEqual([], list(self.object.state().keys()))
self.flushLoggedErrors(ValueError)