本文整理匯總了Python中workflow.workflow.Workflow.clear_data方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow.clear_data方法的具體用法?Python Workflow.clear_data怎麽用?Python Workflow.clear_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類workflow.workflow.Workflow
的用法示例。
在下文中一共展示了Workflow.clear_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: WorkflowTests
# 需要導入模塊: from workflow.workflow import Workflow [as 別名]
# 或者: from workflow.workflow.Workflow import clear_data [as 別名]
#.........這裏部分代碼省略.........
data = {'key7': 'value7'}
self.assertRaises(ValueError, self.wf.store_data, 'test', data,
'spong')
####################################################################
# Data deletion
####################################################################
def test_delete_stored_data(self):
"""Delete stored data"""
data = {'key7': 'value7'}
paths = self._stored_data_paths('test', 'cpickle')
self.wf.store_data('test', data)
self.assertEqual(data, self.wf.stored_data('test'))
self.wf.store_data('test', None)
self.assertEqual(None, self.wf.stored_data('test'))
for p in paths:
self.assertFalse(os.path.exists(p))
def test_delete_all_stored_data_file(self):
"""Stored data are all deleted"""
data = {'key1': 'value1'}
test_file1 = 'test1.cpickle'
test_file2 = 'test2.cpickle'
self.wf.store_data('test1', data)
self.wf.store_data('test2', data)
self.assertTrue(os.path.exists(self.wf.datafile(test_file1)))
self.assertTrue(os.path.exists(self.wf.datafile(test_file2)))
self.wf.clear_data()
self.assertFalse(os.path.exists(self.wf.datafile(test_file1)))
self.assertFalse(os.path.exists(self.wf.datafile(test_file2)))
def test_delete_all_data_file_with_filter_func(self):
"""Only part of stored data are deleted"""
data = {'key1': 'value1'}
test_file1 = 'test1.cpickle'
test_file2 = 'test2.cpickle'
def filter_func(file):
if file == test_file1:
return True
else:
return False
self.wf.store_data('test1', data)
self.wf.store_data('test2', data)
self.assertTrue(os.path.exists(self.wf.datafile(test_file1)))
self.assertTrue(os.path.exists(self.wf.datafile(test_file2)))
self.wf.clear_data(filter_func)
self.assertFalse(os.path.exists(self.wf.datafile(test_file1)))
self.assertTrue(os.path.exists(self.wf.datafile(test_file2)))
self.wf.clear_data()
self.assertFalse(os.path.exists(self.wf.datafile(test_file2)))
####################################################################
# Keychain
####################################################################
def test_keychain(self):
"""Save/get/delete password"""