本文整理匯總了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],
])