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


Python base.User類代碼示例

本文整理匯總了Python中base.User的典型用法代碼示例。如果您正苦於以下問題:Python User類的具體用法?Python User怎麽用?Python User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_delete_group

 def test_delete_group(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name)
     group.create()
     res = group.delete()
     self.assertEqual(res.json()['success'], True)
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:7,代碼來源:test_users.py

示例2: test_patch_group_remove_user

 def test_patch_group_remove_user(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name, users=[bob.email])
     res1 = group.create()
     res2 = group.update(remove_users=[bob.email])
     self.assertEqual(res2.json()['group']['users'], [])
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:7,代碼來源:test_users.py

示例3: test_patch_group_add_site

 def test_patch_group_add_site(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name)
     res1 = group.create()
     res2 = group.update(add_sites=[self.target_url])
     self.assertEqual(res2.json()['group']['sites'][0], self.target_url)
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:7,代碼來源:test_users.py

示例4: test_update_invited_user

 def test_update_invited_user(self):
     #self.start_smtp()
     bob = User(self.email)
     res1 = bob.invite()
     res2 = bob.update(status="active")
     self.assertEqual(res2.json()['user']['status'], 'active')
     self.assertEqual(res1.json()['user']['status'], 'invited')
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:7,代碼來源:test_users.py

示例5: init_data

def init_data():
    """Fish data for project"""
    db.drop_all()
    db.create_all()

    user = User(username='John Doe', email='[email protected]', password='test')
    user.save()
開發者ID:CoolCloud,項目名稱:flask-kit,代碼行數:7,代碼來源:manage.py

示例6: test_update_user

    def test_update_user(self):
        group1 = Group("group1")
        group2 = Group("group2")
        group1.create()
        group2.create()

        # Create a user
        bob = User(self.email, name="Bob", role="user", groups=[group1.group_name])
        res2 = bob.create()
        self.assertEqual(res2.json()['user']['email'], bob.email)
        self.assertEqual(res2.json()['user']['groups'], [group1.group_name])
        self.assertEqual(res2.json()["user"]["role"], "user")

        # Update the user
        res3 = bob.update(name="Bobby", role="administrator", groups=[group2.group_name])
        self.assertEqual(res3.json()["success"], True)
        self.assertEqual(res3.json()['user']['email'], bob.email)
        self.assertEqual(res3.json()['user']['name'], bob.name)
        self.assertEqual(res3.json()['user']['groups'], [group2.group_name])
        self.assertEqual(res3.json()["user"]["role"], "administrator")

        # Make sure the user stored in the db is correct
        res4 = bob.get()
        self.assertEqual(res4.json()['success'], True)
        self.assertEqual(res4.json()['user']['email'], bob.email)
        self.assertEqual(res4.json()['user']['name'], bob.name)
        self.assertEqual(res4.json()['user']['groups'], [group2.group_name])
        self.assertEqual(res4.json()['user']['role'], "administrator")
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:28,代碼來源:test_users.py

示例7: test_get_all_groups

 def test_get_all_groups(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name)
     res1 = group.create()
     res2 = Groups().get()
     self.assertEqual(res2.json()['groups'][0], res1.json()['group'])
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:7,代碼來源:test_users.py

示例8: test_create_duplicate_group

 def test_create_duplicate_group(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name)
     group.create()
     res = group.create()
     self.assertEqual(res.json()['success'], False)
     self.assertEqual(res.json()['reason'], 'group-already-exists')
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:8,代碼來源:test_users.py

示例9: test_get_group

 def test_get_group(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name)
     group.create()
     res = group.get()
     self.assertEqual(res.json()['group']['name'], group.group_name)
     self.assertEqual(res.json()['group']['description'], group.description)
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:8,代碼來源:test_users.py

示例10: test_login_non_active_user

 def test_login_non_active_user(self):
     bob = User(self.email)
     res1 = bob.create()
     # change user to banned
     res2 = bob.update(status="banned")
     res3 = bob.login()
     self.assertEqual(res3.json()['success'], False)
     self.assertEqual(res3.json()['reason'], 'banned')
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:8,代碼來源:test_users.py

示例11: init_data

def init_data():
    """Fish data for project"""
    db.drop_all()
    db.create_all()

    admin = User(
        username=app.config["ADMIN_USERNAME"], email=app.config["ADMIN_EMAIL"], password=app.config["ADMIN_PASSWORD"]
    )
    admin.save()
開發者ID:RockyRoad29,項目名稱:flask-kit,代碼行數:9,代碼來源:manage.py

示例12: test_get_all_users

    def test_get_all_users(self):
        bob = User(self.email)
        bob.create()

        res = Users().get()
        _expected = list(self.expected_inner_keys) + ["sites"]
        self.assertEqual(set(res.json()['users'][0].keys()),
            set(_expected))
        self.assertEqual(1, len(res.json()['users']))
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:9,代碼來源:test_users.py

示例13: test_create_group

 def test_create_group(self):
     bob = User(self.email)
     bob.create()
     group = Group(self.group_name, description=self.group_description)
     res = group.create()
     self.assertEqual(set(res.json().keys()), set(["success", "group"]))
     self.assertEqual(set(res.json()["group"].keys()),
         set(["id", "created", "name", "description", "users", "sites"]))
     self.assertEqual(res.json()['group']['name'], self.group_name)
     self.assertEqual(res.json()['group']['description'], self.group_description)
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:10,代碼來源:test_users.py

示例14: test_sender_not_found

    def test_sender_not_found(self):
        recipient = User(self.random_email(), name="Alice")
        recipient.invite()

        invite = Invite(self.email, recipient.email)
        res = invite.create()

        # sender self.email has not yet been created in minion
        self.assertEqual(res.json()['success'], False)
        self.assertEqual(res.json()['reason'], 'sender-not-found-in-user-record')
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:10,代碼來源:test_invites.py

示例15: test_delete_user

 def test_delete_user(self):
     # Create a user
     bob = User(self.email)
     r = bob.create()
     j = r.json()
     self.assertEqual(True, j['success'])
     # Delete the user
     r = bob.delete()
     self.assertEqual({'success': True}, r.json())
     # Make sure the user is gone
     r = bob.delete()
     self.assertEqual({'success': False, 'reason': 'no-such-user'}, r.json())
開發者ID:PeterMosmans,項目名稱:minion-backend,代碼行數:12,代碼來源:test_users.py


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