当前位置: 首页>>代码示例>>Python>>正文


Python RegisterController.register方法代码示例

本文整理汇总了Python中horus.views.RegisterController.register方法的典型用法代码示例。如果您正苦于以下问题:Python RegisterController.register方法的具体用法?Python RegisterController.register怎么用?Python RegisterController.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horus.views.RegisterController的用法示例。


在下文中一共展示了RegisterController.register方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_register_existing_user

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_existing_user(self):
        from horus.views                import RegisterController
        from pyramid_mailer.mailer      import DummyMailer
        from pyramid_mailer.interfaces  import IMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces           import IActivationClass
        from horus.tests.models         import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')

        admin = User(username='sontek', email='[email protected]')
        admin.password = 'test123'
        self.session.add(admin)
        self.session.flush()

        request = self.get_csrf_request(post={
            'username': 'sontek',
            'password': {
                'password': 'test123',
                'password-confirm': 'test123',
            },
            'email': '[email protected]'
        }, request_method='POST')

        view = RegisterController(request)
        adict = view.register()
        assert isinstance(adict, dict)
        assert adict['errors']
开发者ID:dobrite,项目名称:horus,代码行数:37,代码来源:test_views.py

示例2: test_register_creates_user

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_creates_user(self):
        from horus.views import RegisterController
        from pyramid_mailer.mailer import DummyMailer
        from pyramid_mailer.interfaces import IMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')

        request = self.get_csrf_request(post={
            'username': 'admin',
            'password': {
                'password': 'test123',
                'password-confirm': 'test123',
            },
            'email': '[email protected]'
        }, request_method='POST')

        request.user = Mock()
        controller = RegisterController(request)
        response = controller.register()

        assert response.status_int == 302

        user = User.get_by_username(request, 'admin')

        assert user != None
开发者ID:dobrite,项目名称:horus,代码行数:37,代码来源:test_views.py

示例3: test_register_validation

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_validation(self):
        from horus.views                import RegisterController
        from pyramid_mailer.mailer      import DummyMailer
        from pyramid_mailer.interfaces  import IMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')

        request = self.get_csrf_request(request_method='POST')

        request.user = Mock()
        controller = RegisterController(request)
        response = controller.register()

        assert len(response['errors']) == 3
        assert 'There was a problem with your submission' in response['form']
开发者ID:dobrite,项目名称:horus,代码行数:27,代码来源:test_views.py

示例4: test_register_redirects_if_logged_in

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_redirects_if_logged_in(self):
        from horus.views                import RegisterController
        from pyramid_mailer.mailer      import DummyMailer
        from pyramid_mailer.interfaces  import IMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')
        self.config.registry.settings['horus.login_redirect'] = 'index'
        self.config.registry.settings['horus.logout_redirect'] = 'index'

        request = testing.DummyRequest()
        request.user = Mock()
        controller = RegisterController(request)
        response = controller.register()

        assert response.status_int == 302
开发者ID:dobrite,项目名称:horus,代码行数:27,代码来源:test_views.py

示例5: test_registration_craps_out

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_registration_craps_out(self):
        from horus.views                import RegisterController
        from pyramid_mailer.interfaces  import IMailer
        from horus.interfaces           import IHorusUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IHorusActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IHorusActivationClass)

        self.config.registry.registerUtility(User, IHorusUserClass)

        def send(message):
            raise Exception("I broke!")

        mailer = Mock()
        mailer.send = send

        self.config.include('horus')
        self.config.registry.registerUtility(mailer, IMailer)

        self.config.add_route('index', '/')

        request = self.get_csrf_request(post={
            'Username': 'admin',
            'Password': {
                'Password': 'test123',
                'Password-confirm': 'test123',
            },
            'Email': '[email protected]'
        }, request_method='POST')

        flash = Mock()
        request.session.flash = flash

        request.user = Mock()
        controller = RegisterController(request)
        controller.register()

        flash.assert_called_with('I broke!', 'error')
开发者ID:zerotired,项目名称:horus,代码行数:41,代码来源:test_views.py

示例6: test_register_no_email_validation

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_no_email_validation(self):
        from horus.views import RegisterController
        from pyramid_mailer.mailer import DummyMailer
        from pyramid_mailer.interfaces import IMailer
        from hem.interfaces import IDBSession
        from horus.events import NewRegistrationEvent
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')
        self.config.registry.settings['horus.require_activation'] = False

        def handle_registration(event):
            request = event.request
            session = request.registry.getUtility(IDBSession)
            session.commit()

        self.config.add_subscriber(handle_registration, NewRegistrationEvent)

        request = self.get_csrf_request(post={
            'username': 'admin',
            'password': {
                'password': 'test123',
                'password-confirm': 'test123',
            },
            'email': '[email protected]'
        }, request_method='POST')

        flash = Mock()
        request.session.flash = flash

        request.user = Mock()

        controller = RegisterController(request)
        response = controller.register()

        assert response.status_int == 302

        user = User.get_by_username(request, 'admin')

        assert user.is_activated == True
        flash.assert_called_with(
            'You have been registered, you may log in now!', 'success')
开发者ID:pzatrick,项目名称:horus,代码行数:53,代码来源:test_views.py

示例7: test_register_existing_user

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_existing_user(self):
        from horus.views import RegisterController
        from pyramid_mailer.mailer import DummyMailer
        from pyramid_mailer.interfaces import IMailer
        from horus.interfaces           import IHorusUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IHorusActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IHorusActivationClass)

        self.config.registry.registerUtility(User, IHorusUserClass)

        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.add_route('index', '/')

        admin = User(username='sontek', email='[email protected]')
        admin.set_password('test123')
        self.session.add(admin)
        self.session.flush()

        request = self.get_csrf_request(post={
            'Username': 'sontek',
            'Password': {
                'Password': 'test123',
                'Password-confirm': 'test123',
            },
            'Email': '[email protected]'
        }, request_method='POST')

        flash = Mock()
        request.session.flash = flash

        controller = RegisterController(request)
        controller.register()

        flash.assert_called_with(u'That username is already used.', 'error')
开发者ID:zerotired,项目名称:horus,代码行数:40,代码来源:test_views.py

示例8: test_register_loads_not_logged_in

# 需要导入模块: from horus.views import RegisterController [as 别名]
# 或者: from horus.views.RegisterController import register [as 别名]
    def test_register_loads_not_logged_in(self):
        from horus.views                import RegisterController
        from pyramid_mailer.mailer      import DummyMailer
        from pyramid_mailer.interfaces  import IMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        self.config.include('horus')

        self.config.add_route('index', '/')

        request = testing.DummyRequest()
        request.user = None
        controller = RegisterController(request)
        response = controller.register()

        assert response.get('form', None)
开发者ID:dobrite,项目名称:horus,代码行数:25,代码来源:test_views.py


注:本文中的horus.views.RegisterController.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。