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


Python User.example方法代碼示例

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


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

示例1: test_can_redirect_to_domains_on_same_domain_after_login

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_can_redirect_to_domains_on_same_domain_after_login(self, came_from):
     user = User.example()
     quoted_came_from = urllib.quote_plus(came_from)
     request = self.init_fake_request(server_name='server.example',
         request_uri='/login/post_login?came_from='+quoted_came_from)
     response = self.call_post_login(user, request=request)
     assert_equals(came_from, response.location)
開發者ID:knyar,項目名稱:mediadrop,代碼行數:9,代碼來源:login_test.py

示例2: test_handles_bad_came_from_parameter_gracefully

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_handles_bad_came_from_parameter_gracefully(self):
     user = User.example()
     quoted_came_from = urllib.quote_plus('invalid junk')
     request = self.init_fake_request(server_name='server.example',
         request_uri='/login/post_login?came_from='+quoted_came_from)
     response = self.call_post_login(user, request=request)
     assert_equals('http://server.example:80/', response.location)
開發者ID:knyar,項目名稱:mediadrop,代碼行數:9,代碼來源:login_test.py

示例3: test_uses_correct_redirect_url_if_mediadrop_is_mounted_in_subdirectory

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
    def test_uses_correct_redirect_url_if_mediadrop_is_mounted_in_subdirectory(self):
        user = User.example()

        request = self.init_fake_request(server_name="server.example", request_uri="/login/post_login")
        request.environ["SCRIPT_NAME"] = "my_media"

        response = self.call_post_login(user, request=request)
        assert_equals("http://server.example:80/my_media/", response.location)
開發者ID:GitReadysoft,項目名稱:mediadrop,代碼行數:10,代碼來源:login_test.py

示例4: test_non_editors_are_redirect_to_home_page_after_login

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_non_editors_are_redirect_to_home_page_after_login(self):
     user = User.example()
     perm = MediaDropPermissionSystem.permissions_for_user(user, config)
     assert_false(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     
     response = self.call_post_login(user)
     assert_equals('http://server.example:80/', response.location)
開發者ID:knyar,項目名稱:mediadrop,代碼行數:10,代碼來源:login_test.py

示例5: test_prevent_parameter_base_redirection

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
    def test_prevent_parameter_base_redirection(self):
        user = User.example()

        came_from = urllib.quote_plus('http://evil.site/malware/')
        request = self.init_fake_request(server_name='server.example',
            request_uri='/login/post_login?came_from='+came_from)
        response = self.call_post_login(user, request=request)
        assert_equals('http://server.example:80/', response.location,
            message='should only redirect to urls on the same domain')
開發者ID:knyar,項目名稱:mediadrop,代碼行數:11,代碼來源:login_test.py

示例6: test_uses_correct_redirect_url_if_mediadrop_is_mounted_in_subdirectory

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_uses_correct_redirect_url_if_mediadrop_is_mounted_in_subdirectory(self):
     user = User.example()
     
     request = self.init_fake_request(server_name='server.example',
         request_uri='/login/post_login')
     request.environ['SCRIPT_NAME'] = 'my_media'
     
     response = self.call_post_login(user, request=request)
     assert_equals('http://server.example:80/my_media/', response.location)
開發者ID:knyar,項目名稱:mediadrop,代碼行數:11,代碼來源:login_test.py

示例7: test_can_create_example_user

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_can_create_example_user(self):
     user = User.example()
     
     assert_not_none(user.id)
     assert_equals(u'joe', user.user_name)
     assert_equals(u'Joe Smith', user.display_name)
     assert_equals(u'[email protected]', user.email_address)
     assert_almost_equals(datetime.now(), user.created, 
                          max_delta=timedelta(seconds=1))
開發者ID:SmallsLIVE,項目名稱:mediadrop,代碼行數:11,代碼來源:user_example_test.py

示例8: _create_user_with_admin_permission_only

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def _create_user_with_admin_permission_only(self):
     admin_perm = DBSession.query(Permission).filter(Permission.permission_name == u'admin').one()
     second_admin_group = Group.example(name=u'Second admin group')
     admin_perm.groups.append(second_admin_group)
     admin = User.example(groups=[second_admin_group])
     DBSession.commit()
     perm = MediaDropPermissionSystem.permissions_for_user(admin, config)
     assert_true(perm.contains_permission(u'admin'))
     assert_false(perm.contains_permission(u'edit'))
     return admin
開發者ID:knyar,項目名稱:mediadrop,代碼行數:12,代碼來源:login_test.py

示例9: _create_user_with_edit_permission_only

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def _create_user_with_edit_permission_only(self):
     editor = User.example(groups=[self.editor_group()])
     perm = MediaDropPermissionSystem.permissions_for_user(editor, config)
     assert_true(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     return editor
開發者ID:knyar,項目名稱:mediadrop,代碼行數:8,代碼來源:login_test.py

示例10: test_can_override_example_data

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_can_override_example_data(self):
     user = User.example(display_name=u'Bar Foo')
     
     assert_equals(u'Bar Foo', user.display_name)
開發者ID:SmallsLIVE,項目名稱:mediadrop,代碼行數:6,代碼來源:user_example_test.py

示例11: test_permits_access_if_user_is_logged_in

# 需要導入模塊: from mediadrop.model import User [as 別名]
# 或者: from mediadrop.model.User import example [as 別名]
 def test_permits_access_if_user_is_logged_in(self):
     request = self.init_fake_request()
     self.set_authenticated_user(User.example())
     assert_true(is_logged_in().has_required_permission(request))
開發者ID:FelixSchwarz,項目名稱:mediadrop-test-renames,代碼行數:6,代碼來源:is_logged_in_decorator_test.py


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