本文整理汇总了Python中shinysdr.values.CollectionState.state方法的典型用法代码示例。如果您正苦于以下问题:Python CollectionState.state方法的具体用法?Python CollectionState.state怎么用?Python CollectionState.state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shinysdr.values.CollectionState
的用法示例。
在下文中一共展示了CollectionState.state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestStateInsert
# 需要导入模块: from shinysdr.values import CollectionState [as 别名]
# 或者: from shinysdr.values.CollectionState import state [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 [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)
示例3: TestCollectionStream
# 需要导入模块: from shinysdr.values import CollectionState [as 别名]
# 或者: from shinysdr.values.CollectionState import state [as 别名]
class TestCollectionStream(StateStreamTestCase):
def setUp(self):
self.d = {'a': ExportedState()}
self.object = CollectionState(self.d, dynamic=True)
StateStreamTestCase.setUp(self)
def test_delete(self):
self.assertEqual(self.getUpdates(), [
['register_block', 1, 'urlroot'],
['register_cell', 2, 'urlroot/a', self.object.state()['a'].description()],
['register_block', 3, 'urlroot/a'],
['value', 3, {}],
['value', 2, 3],
['value', 1, {'a': 2}],
['value', 0, 1],
])
self.assertEqual(self.getUpdates(), [])
del self.d['a']
self.assertEqual(self.getUpdates(), [
['value', 1, {}],
['delete', 2],
['delete', 3],
])