本文整理匯總了Python中dbclient.DbClient.getTrustedContacts方法的典型用法代碼示例。如果您正苦於以下問題:Python DbClient.getTrustedContacts方法的具體用法?Python DbClient.getTrustedContacts怎麽用?Python DbClient.getTrustedContacts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dbclient.DbClient
的用法示例。
在下文中一共展示了DbClient.getTrustedContacts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testGetProfile
# 需要導入模塊: from dbclient import DbClient [as 別名]
# 或者: from dbclient.DbClient import getTrustedContacts [as 別名]
def testGetProfile(self):
# Delete whole profiles table
DbClient._getProfileTable().remove({})
self.assertEqual(DbClient._getProfileTable().count(), 0, "Profiles table should be empty")
# Add own profile
myTorId = "ABC123DEF456GH78"
myprofile = {"name" : "Constantin Taylor", "keyid" : "someKeyId", "displayName" : "Me",
"status" : "self", "ownprofile" : True}
DbClient.updateContact(myTorId, myprofile)
self.assertEqual(DbClient._getProfileTable().count(), 1, "Profiles table should have my profile in it")
profileFromDb = DbClient.getProfile(None)
self.assertIsNotNone(profileFromDb, "Couldn't retrieve own profile")
profileFromDb = DbClient.getProfile(myTorId)
self.assertIsNotNone(profileFromDb, "Couldn't retrieve profile using own id")
# Initiate contact with a new person
otherTorId = "PQR123STU456VWX78"
otherName = "Olivia Barnacles"
DbClient.updateContact(otherTorId, {"status" : "untrusted", "keyid" : "donotknow", "name" : otherName})
self.assertEqual(DbClient._getProfileTable().count(), 2, "Profiles table should have 2 profiles")
self.assertEqual(DbClient.getMessageableContacts().count(), 1, "Profiles table should have 1 messageable")
self.assertEqual(DbClient.getTrustedContacts().count(), 0, "Profiles table should have 0 trusted")
profileFromDb = DbClient.getProfile(otherTorId)
self.assertIsNotNone(profileFromDb, "Couldn't retrieve profile using other id")
self.assertEqual(profileFromDb.get("name", None), otherName, "Profile name doesn't match what was stored")
self.assertEqual(profileFromDb.get("status", None), "untrusted", "Profile status doesn't match what was stored")
# Update existing record, change status
DbClient.updateContact(otherTorId, {"status" : "trusted"})
self.assertEqual(DbClient._getProfileTable().count(), 2, "Profiles table should still have 2 profiles")
profileFromDb = DbClient.getProfile(otherTorId)
self.assertIsNotNone(profileFromDb, "Couldn't retrieve profile using other id")
self.assertEqual(profileFromDb.get("status", None), "trusted", "Profile status should have been updated")
self.assertEqual(DbClient.getMessageableContacts().count(), 1, "Profiles table should have 1 messageable")
self.assertEqual(DbClient.getTrustedContacts().count(), 1, "Profiles table should have 1 trusted")
# Delete other contact
DbClient.updateContact(otherTorId, {"status" : "deleted"})
self.assertEqual(DbClient.getMessageableContacts().count(), 0, "Profiles table should have 0 messageable")
self.assertEqual(DbClient.getTrustedContacts().count(), 0, "Profiles table should have 0 trusted")
self.assertFalse(DbClient.hasFriends(), "Shouldn't have any friends any more")