當前位置: 首頁>>代碼示例>>Python>>正文


Python User.data['university']方法代碼示例

本文整理匯總了Python中src.models.user.User.data['university']方法的典型用法代碼示例。如果您正苦於以下問題:Python User.data['university']方法的具體用法?Python User.data['university']怎麽用?Python User.data['university']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在src.models.user.User的用法示例。


在下文中一共展示了User.data['university']方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_user_json

# 需要導入模塊: from src.models.user import User [as 別名]
# 或者: from src.models.user.User import data['university'] [as 別名]
    def test_user_json(self):
        email = "[email protected]"
        encrypted_password = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
        country = "Spain"
        university = "Abertay"

        user = User(email, encrypted_password)
        user.permissions = Permissions.default().name
        user.data['country'] = country
        user.data['university'] = university

        self.assertEqual(user.json(),
                         {
                             "email": email,
                             "password": encrypted_password,
                             "country": country,
                             "university": university,
                             "permissions": "user"
                         })
開發者ID:jslvtr,項目名稱:AC41004-Team-2,代碼行數:21,代碼來源:test_user.py

示例2: test_save_complex_user_to_db

# 需要導入模塊: from src.models.user import User [as 別名]
# 或者: from src.models.user.User import data['university'] [as 別名]
    def test_save_complex_user_to_db(self):
        email = "[email protected]"
        encrypted_password = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
        country = "Spain"
        university = "Abertay"

        user = User(email, encrypted_password)
        user.data['country'] = country
        user.data['university'] = university
        user.permissions = Permissions.default().name
        user.save_to_db()

        user_from_db = User.find_by_email(email)

        self.assertEqual(user_from_db.email, email)
        self.assertEqual(user_from_db.encrypted_password, encrypted_password)
        self.assertEqual(user_from_db.data['country'], country)
        self.assertEqual(user_from_db.data['university'], university)

        Database.remove("users", {"email": email})
開發者ID:jslvtr,項目名稱:AC41004-Team-2,代碼行數:22,代碼來源:test_user.py


注:本文中的src.models.user.User.data['university']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。