本文整理汇总了Python中resync.resource.Resource.md5方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.md5方法的具体用法?Python Resource.md5怎么用?Python Resource.md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resync.resource.Resource
的用法示例。
在下文中一共展示了Resource.md5方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_resource_str_hashes
# 需要导入模块: from resync.resource import Resource [as 别名]
# 或者: from resync.resource.Resource import md5 [as 别名]
def test_03_resource_str_hashes(self):
r1 = Resource('03hashes',1234.1)
r1.md5 = 'aaa'
r1.sha1 = 'bbb'
self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb\" /></url>" )
r1.sha256 = 'ccc'
self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb sha-256:ccc\" /></url>" )
r1.sha1 = None
self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-256:ccc\" /></url>" )
示例2: test6_has_md5
# 需要导入模块: from resync.resource import Resource [as 别名]
# 或者: from resync.resource.Resource import md5 [as 别名]
def test6_has_md5(self):
r1 = Resource(uri='a')
r2 = Resource(uri='b')
i = ResourceList()
self.assertFalse( i.has_md5() )
i.add(r1)
i.add(r2)
self.assertFalse( i.has_md5() )
r1.md5="aabbcc"
self.assertTrue( i.has_md5() )
示例3: test6_has_md5
# 需要导入模块: from resync.resource import Resource [as 别名]
# 或者: from resync.resource.Resource import md5 [as 别名]
def test6_has_md5(self):
r1 = Resource(uri="a")
r2 = Resource(uri="b")
m = Inventory()
self.assertFalse(m.has_md5())
m.add(r1)
m.add(r2)
self.assertFalse(m.has_md5())
r1.md5 = "aabbcc"
self.assertTrue(m.has_md5())
示例4: test07_hashes
# 需要导入模块: from resync.resource import Resource [as 别名]
# 或者: from resync.resource.Resource import md5 [as 别名]
def test07_hashes(self):
r1 = Resource(uri='a')
r2 = Resource(uri='b')
i = ResourceList()
self.assertEqual(i.hashes(), set())
i.add(r1)
i.add(r2)
self.assertEqual(i.hashes(), set())
r1.md5 = "aabbcc"
self.assertEqual(i.hashes(), set(['md5']))
r2.sha1 = "ddeeff"
self.assertEqual(i.hashes(), set(['md5', 'sha-1']))
示例5: test08_multiple_hashes
# 需要导入模块: from resync.resource import Resource [as 别名]
# 或者: from resync.resource.Resource import md5 [as 别名]
def test08_multiple_hashes(self):
r1 = Resource('abcd')
r1.md5 = "some_md5"
r1.sha1 = "some_sha1"
r1.sha256 = "some_sha256"
self.assertEqual( r1.md5, "some_md5" )
self.assertEqual( r1.sha1, "some_sha1" )
self.assertEqual( r1.sha256, "some_sha256" )
self.assertEqual( r1.hash, "md5:some_md5 sha-1:some_sha1 sha-256:some_sha256" )
r2 = Resource('def')
r2.hash = "md5:ddd"
self.assertEqual( r2.md5, 'ddd' )
self.assertEqual( r2.sha1, None )
r2.hash = "sha-1:eee"
self.assertEqual( r2.md5, None )
self.assertEqual( r2.sha1, 'eee' )
r2.hash = "md5:fff sha-1:eee sha-256:ggg"
self.assertEqual( r2.md5, 'fff' )
self.assertEqual( r2.sha1, 'eee' )
self.assertEqual( r2.sha256, 'ggg' )