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


Python Mock.provenance方法代码示例

本文整理汇总了Python中mock.Mock.provenance方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.provenance方法的具体用法?Python Mock.provenance怎么用?Python Mock.provenance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.Mock的用法示例。


在下文中一共展示了Mock.provenance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Keep_accepts_bsonBinary

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Keep_accepts_bsonBinary(self):
     from niprov.pictures import PictureCache
     myImg = Mock()
     myImg.provenance = {'id':'007'}
     pictures = PictureCache(sentinel.dependencies)
     pictures.keep(bson.Binary('/x10/x05/x5f'), for_=myImg)
     self.assertEqual('/x10/x05/x5f', pictures.getBytes(for_=myImg))
开发者ID:ilogue,项目名称:niprov,代码行数:9,代码来源:test_pictures.py

示例2: test_update

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_update(self):
     self.setupRepo()
     img = Mock()
     img.provenance = {'a':1, 'b':2}
     self.repo.update(img)
     self.db.provenance.update.assert_called_with(
         {'location':img.location.toString()}, {'a':1, 'b':2})
开发者ID:ilogue,项目名称:niprov,代码行数:9,代码来源:test_MongoRepo.py

示例3: test_copiesOf

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_copiesOf(self):
     from niprov.querying import Query
     target = Mock()
     target.provenance = {'hash':'a7b8c9', 'size':1}
     q = Query(self.dependencies).copiesOf(target)
     self.assertEqual(1, len(q.getFields()))
     self.assertEqual('hash', q.getFields()[0].name)
     self.assertEqual('a7b8c9', q.getFields()[0].value)
开发者ID:ilogue,项目名称:niprov,代码行数:10,代码来源:test_query.py

示例4: test_If_no_snapshot_doesnt_add_data_field

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_If_no_snapshot_doesnt_add_data_field(self):
     self.pictureCache.getBytes.return_value = None
     with patch('niprov.mongo.bson') as bson:
         self.setupRepo()
         img = Mock()
         img.provenance = {'a':1}
         self.repo.add(img)
         assert not bson.Binary.called
         self.db.provenance.insert_one.assert_called_with({'a':1})
开发者ID:ilogue,项目名称:niprov,代码行数:11,代码来源:test_MongoRepo.py

示例5: test_Stored_picture_can_be_retrieved_as_filepath

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Stored_picture_can_be_retrieved_as_filepath(self):
     from niprov.pictures import PictureCache
     myImg = Mock()
     myImg.provenance = {'id':'007'}
     pictures = PictureCache(sentinel.dependencies)
     self.assertIsNone(pictures.getFilepath(for_=myImg))
     pictures.keep(io.BytesIO('/x10/x05/x5f'), for_=myImg)
     picfpath = os.path.expanduser('~/.niprov-snapshots/007.png')
     self.assertEqual(picfpath, pictures.getFilepath(for_=myImg))
开发者ID:ilogue,项目名称:niprov,代码行数:11,代码来源:test_pictures.py

示例6: test_If_pic_is_not_in_cache_but_on_filesystem_provides_that

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_If_pic_is_not_in_cache_but_on_filesystem_provides_that(self):
     import niprov.pictures
     myImg = Mock()
     myImg.provenance = {'id':'007'}
     pictures = niprov.pictures.PictureCache(sentinel.dependencies)
     pictures.keep(io.BytesIO('/x10/x05/x5f'), for_=myImg)
     pictures.saveToDisk(for_=myImg)
     niprov.pictures._CACHE = {} # reset cache
     picfpath = os.path.expanduser('~/.niprov-snapshots/007.png')
     self.assertEqual(picfpath, pictures.getFilepath(for_=myImg))
开发者ID:ilogue,项目名称:niprov,代码行数:12,代码来源:test_pictures.py

示例7: test_Stored_picture_can_be_retrieved_as_bytes

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Stored_picture_can_be_retrieved_as_bytes(self):
     from niprov.pictures import PictureCache
     myImg = Mock()
     myImg.provenance = {'id':'007'}
     pictures = PictureCache(sentinel.dependencies)
     newPicture = pictures.new()
     newPicture.write('/x10/x05/x5f')
     pictures.keep(newPicture, for_=myImg)
     outBytes = pictures.getBytes(for_=myImg)
     self.assertEqual('/x10/x05/x5f', outBytes)
开发者ID:ilogue,项目名称:niprov,代码行数:12,代码来源:test_pictures.py

示例8: test_keepVersionsFromPrevious

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_keepVersionsFromPrevious(self):
     img = self.constructor(self.path, dependencies=self.dependencies)
     prev = Mock()
     prev.provenance = {'y':1501, '_versions':[{'y':1499},{'y':1500}]}
     img.keepVersionsFromPrevious(prev)
     self.assertEqual('new-version', img.status)
     self.assertEqual(3, len(img.provenance['_versions']))
     self.assertEqual({'y':1501}, img.provenance['_versions'][-1])
     self.assertEqual({'y':1500}, img.provenance['_versions'][-2])
     self.assertEqual({'y':1499}, img.provenance['_versions'][-3])
开发者ID:ilogue,项目名称:niprov,代码行数:12,代码来源:test_basefile.py

示例9: test_Found_copy_set_as_parent_inherits_and_flags_and_informs_listener

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Found_copy_set_as_parent_inherits_and_flags_and_informs_listener(self):
     self.img.provenance = {}
     copy = Mock()
     copy.provenance = {'location':'copy-location'}
     self.query.copiesOf.return_value = [self.img, copy]
     out = self.add('p/afile.f')
     self.inheritFrom.assert_called_with(self.img.provenance, copy.provenance)
     self.listener.usingCopyAsParent.assert_called_with(copy)
     self.assertEqual(copy.location.toString(), out.provenance['parents'][0])
     self.assertEqual(True, out.provenance['copy-as-parent'])
开发者ID:ilogue,项目名称:niprov,代码行数:12,代码来源:test_add.py

示例10: test_Can_be_told_to_persist_picture_to_disk_now

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Can_be_told_to_persist_picture_to_disk_now(self):
     from niprov.pictures import PictureCache
     myImg = Mock()
     myImg.provenance = {'id':'007'}
     pictures = PictureCache(sentinel.dependencies)
     pictures.saveToDisk(for_=myImg) #shouldn't do anything
     pictures.keep(io.BytesIO('/x10/x05/x5f'), for_=myImg)
     pictures.saveToDisk(for_=myImg)
     picfpath = os.path.expanduser('~/.niprov-snapshots/007.png')
     self.assertTrue(os.path.isfile(picfpath))
     with open(picfpath) as picFile:
         self.assertEqual(picFile.read(), '/x10/x05/x5f')
开发者ID:ilogue,项目名称:niprov,代码行数:14,代码来源:test_pictures.py

示例11: test_Obtains_optional_snapshot_data_from_cache_when_serializing

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_Obtains_optional_snapshot_data_from_cache_when_serializing(self):
     self.pictureCache.getBytes.return_value = sentinel.snapbytes
     with patch('niprov.mongo.bson') as bson:
         bson.Binary.return_value = sentinel.snapbson
         self.setupRepo()
         img = Mock()
         img.provenance = {'a':1}
         self.repo.add(img)
         self.pictureCache.getBytes.assert_called_with(for_=img)
         bson.Binary.assert_called_with(sentinel.snapbytes)
         self.db.provenance.insert_one.assert_called_with({'a':1, 
             '_snapshot-data':sentinel.snapbson})
开发者ID:ilogue,项目名称:niprov,代码行数:14,代码来源:test_MongoRepo.py

示例12: test_updateApproval

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_updateApproval(self):
     from niprov.jsonfile import JsonFile
     repo = JsonFile(self.dependencies)
     img = Mock()
     img.provenance = {'fiz':'baf','approval':'notsure'}
     def assertion(img):
         self.assertEqual({'fiz':'baf','approval':'excellent!'}, img.provenance)
     repo.byLocation = Mock()
     repo.byLocation.return_value = img
     repo.update = Mock()
     repo.update.side_effect = assertion
     repo.updateApproval('/p/f1','excellent!')
开发者ID:ilogue,项目名称:niprov,代码行数:14,代码来源:test_jsonfile.py

示例13: test_File

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_File(self):
     from niprov.formatnarrated import NarratedFormat
     img = Mock()
     p = {}
     p['protocol'] = 'T1'
     p['acquired'] = datetime(2013, 9, 7, 11, 27, 34)
     p['subject'] = 'John Doe'
     p['size'] = 345123
     img.provenance = p
     storyteller = NarratedFormat()
     self.assertEqual(storyteller.serializeSingle(img), ("This is a T1 image. "
         "It was recorded September 7, 2013. "
         "The participant's name is John Doe. "
         "It is 345KB in size. "))
开发者ID:ilogue,项目名称:niprov,代码行数:16,代码来源:test_formatnarrated.py

示例14: test_fileAdded

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def test_fileAdded(self):
     from niprov.commandline import Commandline
     self.dependencies.config.verbosity = 'info'
     cmd = Commandline(self.dependencies)
     cmd.log = Mock()
     img = Mock()
     img.path = 'xyz'
     img.status = 'new'
     cmd.fileAdded(img)
     cmd.log.assert_called_with('info', 'New file: xyz')
     img.status = 'series-new-file'
     img.provenance = {'filesInSeries':[1, 2, 3]}
     img.getSeriesId.return_value = 'series987'
     cmd.fileAdded(img)
     cmd.log.assert_called_with('info', 'Added 3rd file to series: series987')
     img.status = 'new-version'
     cmd.fileAdded(img)
     cmd.log.assert_called_with('info', 'Added new version for: xyz')
开发者ID:ilogue,项目名称:niprov,代码行数:20,代码来源:test_commandline.py

示例15: aFile

# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import provenance [as 别名]
 def aFile(self):
     somefile = Mock()
     somefile.provenance = {'a':'b'}
     return somefile
开发者ID:ilogue,项目名称:niprov,代码行数:6,代码来源:test_formatobject.py


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