本文整理汇总了Python中pyndn.Name.equals方法的典型用法代码示例。如果您正苦于以下问题:Python Name.equals方法的具体用法?Python Name.equals怎么用?Python Name.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Name
的用法示例。
在下文中一共展示了Name.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_append
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import equals [as 别名]
def test_append(self):
# could possibly split this into different tests
uri = "/localhost/user/folders/files/%00%0F"
name = Name(uri)
name2 = Name("/localhost").append(Name("/user/folders/"))
self.assertEqual(name2.size(), 3, 'Name constructed by appending names has ' + str(name2.size()) + ' components instead of 3')
self.assertTrue(name2.get(2).getValue().equals(Blob(bytearray("folders"))), 'Name constructed with append has wrong suffix')
name2 = name2.append("files")
self.assertEqual(name2.size(), 4, 'Name constructed by appending string has ' + str(name2.size()) + ' components instead of 4')
name2 = name2.appendSegment(15)
self.assertTrue(name2.get(4).getValue().equals(Blob(bytearray([0x00, 0x0F]))), 'Name constructed by appending segment has wrong segment value')
self.assertTrue(name2.equals(name), 'Name constructed with append is not equal to URI constructed name')
self.assertEqual(name2.toUri(), name.toUri(), 'Name constructed with append has wrong URI')
示例2: test_subname
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import equals [as 别名]
def test_subname(self):
name = Name("/edu/cmu/andrew/user/3498478")
subName1 = name.getSubName(0)
self.assertTrue(subName1.equals(name), 'Subname from first component does not match original name')
subName2 = name.getSubName(3)
self.assertEqual(subName2.toUri(), "/user/3498478")
subName3 = name.getSubName(1,3)
self.assertEqual(subName3.toUri(), "/cmu/andrew/user")
subName4 = name.getSubName(0,100)
self.assertTrue(name.equals(subName4), 'Subname with more components than original should stop at end of original name')
subName5 = name.getSubName(7,9)
self.assertTrue(Name().equals(subName5), 'Subname beginning after end of name should be empty')
示例3: test_basic
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import equals [as 别名]
def test_basic(self):
identityName = Name("/my-identity")
keyName = Name("/my-key")
certificateName = Name("/my-cert")
info = SigningInfo()
self.assertEqual(SigningInfo.SignerType.NULL, info.getSignerType())
self.assertTrue(Name().equals(info.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, info.getDigestAlgorithm())
info.setSigningIdentity(identityName)
self.assertEqual(SigningInfo.SignerType.ID, info.getSignerType())
self.assertTrue(identityName.equals(info.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, info.getDigestAlgorithm())
infoId = SigningInfo(SigningInfo.SignerType.ID, identityName)
self.assertEqual(SigningInfo.SignerType.ID, infoId.getSignerType())
self.assertTrue(identityName.equals(infoId.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, infoId.getDigestAlgorithm())
info.setSigningKeyName(keyName)
self.assertEqual(SigningInfo.SignerType.KEY, info.getSignerType())
self.assertTrue(keyName.equals(info.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, info.getDigestAlgorithm())
infoKey = SigningInfo(SigningInfo.SignerType.KEY, keyName)
self.assertEqual(SigningInfo.SignerType.KEY, infoKey.getSignerType())
self.assertTrue(keyName.equals(infoKey.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, infoKey.getDigestAlgorithm())
info.setSigningCertificateName(certificateName)
self.assertEqual(SigningInfo.SignerType.CERT, info.getSignerType())
self.assertTrue(certificateName.equals(info.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, info.getDigestAlgorithm())
infoCert = SigningInfo(SigningInfo.SignerType.CERT, certificateName)
self.assertEqual(SigningInfo.SignerType.CERT, infoCert.getSignerType())
self.assertTrue(certificateName.equals(infoCert.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, infoCert.getDigestAlgorithm())
info.setSha256Signing()
self.assertEqual(SigningInfo.SignerType.SHA256, info.getSignerType())
self.assertTrue(Name().equals(info.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, info.getDigestAlgorithm())
infoSha256 = SigningInfo(SigningInfo.SignerType.SHA256)
self.assertEqual(SigningInfo.SignerType.SHA256, infoSha256.getSignerType())
self.assertTrue(Name().equals(infoSha256.getSignerName()))
self.assertEqual(DigestAlgorithm.SHA256, infoSha256.getDigestAlgorithm())
示例4: test_copy_constructor
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import equals [as 别名]
def test_copy_constructor(self):
name = Name(self.expectedURI)
name2 = Name(name)
self.assertTrue(name.equals(name2), 'Name from copy constructor does not match original')