當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。