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


Python DummyRequest.remote_addr方法代码示例

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


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

示例1: test_valid

# 需要导入模块: from ccvpn.tests import DummyRequest [as 别名]
# 或者: from ccvpn.tests.DummyRequest import remote_addr [as 别名]
    def test_valid(self):
        req = DummyRequest(post={
            'password': 'newpw',
            'password2': 'newpw',
        })
        req.matchdict['token'] = self.token.token
        req.remote_addr = '127.0.0.1'
        resp = views.account.reset(req)
        self.assertIsInstance(resp, httpexceptions.HTTPMovedPermanently)
        self.assertTrue(resp.location.endswith('/account/login'))

        registry = self.config.registry
        mailer = get_mailer(registry)
        self.assertEqual(len(mailer.outbox), 1)

        # Should not be able to use a token > 1 time
        req = DummyRequest(post={
            'password': 'newpw',
            'password2': 'newpw',
        })
        req.matchdict['token'] = self.token.token
        req.remote_addr = '127.0.0.1'
        resp = views.account.reset(req)
        self.assertIsInstance(resp, httpexceptions.HTTPMovedPermanently)
        self.assertTrue(resp.location.endswith('/account/forgot'))

        registry = self.config.registry
        mailer = get_mailer(registry)
        self.assertEqual(len(mailer.outbox), 1)
开发者ID:CCrypto,项目名称:ccvpn2,代码行数:31,代码来源:views_account.py

示例2: test_form

# 需要导入模块: from ccvpn.tests import DummyRequest [as 别名]
# 或者: from ccvpn.tests.DummyRequest import remote_addr [as 别名]
    def test_form(self):
        req = DummyRequest()
        req.matchdict['token'] = self.token.token
        req.remote_addr = '127.0.0.1'
        resp = views.account.reset(req)
        self.assertEqual(req.response.status_code, 200)
        self.assertIsInstance(resp, dict)

        req = DummyRequest(post={})
        req.matchdict['token'] = self.token.token
        req.remote_addr = '127.0.0.1'
        resp = views.account.reset(req)
        self.assertEqual(req.response.status_code, 200)
        self.assertIsInstance(resp, dict)
开发者ID:CCrypto,项目名称:ccvpn2,代码行数:16,代码来源:views_account.py

示例3: test_invalid_email

# 需要导入模块: from ccvpn.tests import DummyRequest [as 别名]
# 或者: from ccvpn.tests.DummyRequest import remote_addr [as 别名]
 def test_invalid_email(self):
     req = DummyRequest(post={
         'username': 'testWOemail',
     })
     req.remote_addr = '127.0.0.1'
     resp = views.account.forgot(req)
     self.assertEqual(req.response.status_code, 400)
     self.assertIsInstance(resp, dict)
开发者ID:CCrypto,项目名称:ccvpn2,代码行数:10,代码来源:views_account.py

示例4: test_invalid_password

# 需要导入模块: from ccvpn.tests import DummyRequest [as 别名]
# 或者: from ccvpn.tests.DummyRequest import remote_addr [as 别名]
 def test_invalid_password(self):
     req = DummyRequest(post={
         'password': 'pw',
         'password2': 'notpw'
     })
     req.matchdict['token'] = self.token.token
     req.remote_addr = '127.0.0.1'
     resp = views.account.reset(req)
     self.assertEqual(req.response.status_code, 400)
     self.assertIsInstance(resp, dict)
开发者ID:CCrypto,项目名称:ccvpn2,代码行数:12,代码来源:views_account.py

示例5: test_invalid_token

# 需要导入模块: from ccvpn.tests import DummyRequest [as 别名]
# 或者: from ccvpn.tests.DummyRequest import remote_addr [as 别名]
 def test_invalid_token(self):
     req = DummyRequest()
     req.matchdict['token'] = 'invalidtoken'
     req.remote_addr = '127.0.0.1'
     resp = views.account.reset(req)
     self.assertIsInstance(resp, httpexceptions.HTTPMovedPermanently)
开发者ID:CCrypto,项目名称:ccvpn2,代码行数:8,代码来源:views_account.py


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