当前位置: 首页>>代码示例>>Python>>正文


Python CollectionState.state方法代码示例

本文整理汇总了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())
开发者ID:nunb,项目名称:shinysdr,代码行数:22,代码来源:test_values.py

示例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)
开发者ID:kpreid,项目名称:shinysdr,代码行数:24,代码来源:test_values.py

示例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],
		])
开发者ID:WindyCitySDR,项目名称:shinysdr,代码行数:25,代码来源:test_web.py


注:本文中的shinysdr.values.CollectionState.state方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。