• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.override_setting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中misago.conf.settings.override_setting函数的典型用法代码示例。如果您正苦于以下问题:Python override_setting函数的具体用法?Python override_setting怎么用?Python override_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_registration_off_request

    def test_registration_off_request(self):
        """registrations off request errors with code 403"""
        settings.override_setting('account_activation', 'closed')

        response = self.client.post('/api/users/')
        self.assertEqual(response.status_code, 403)
        self.assertIn('closed', response.content)
开发者ID:h094071,项目名称:Misago,代码行数:7,代码来源:test_user_create_api.py


示例2: test_registration_creates_user_with_whitespace_password

    def test_registration_creates_user_with_whitespace_password(self):
        """api creates user with spaces around password"""
        settings.override_setting('account_activation', 'none')

        response = self.client.post(
            self.api_link,
            data={
                'username': 'Bob',
                'email': '[email protected]',
                'password': ' pass123 ',
            },
        )

        self.assertContains(response, 'active')
        self.assertContains(response, 'Bob')
        self.assertContains(response, '[email protected]')

        UserModel.objects.get_by_username('Bob')

        test_user = UserModel.objects.get_by_email('[email protected]')
        self.assertEqual(Online.objects.filter(user=test_user).count(), 1)

        self.assertTrue(test_user.check_password(' pass123 '))

        response = self.client.get(reverse('misago:index'))
        self.assertContains(response, 'Bob')

        self.assertIn('Welcome', mail.outbox[0].subject)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:28,代码来源:test_user_create_api.py


示例3: test_context_processor_misago_tos

    def test_context_processor_misago_tos(self):
        """context processor has TOS link to Misago view"""
        settings.override_setting('terms_of_service', 'Lorem ipsum')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'TERMS_OF_SERVICE_URL': reverse('misago:terms-of-service')
        })
开发者ID:1905410,项目名称:Misago,代码行数:8,代码来源:tests.py


示例4: test_context_processor_misago_policy

    def test_context_processor_misago_policy(self):
        """context processor has TOS link to Misago view"""
        settings.override_setting('privacy_policy', 'Lorem ipsum')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'PRIVACY_POLICY_URL': reverse('misago:privacy-policy')
        })
开发者ID:1905410,项目名称:Misago,代码行数:8,代码来源:tests.py


示例5: test_301_on_link_policy

    def test_301_on_link_policy(self):
        """policy view returns 302 redirect when link is set"""
        settings.override_setting('privacy_policy_link', 'http://test.com')
        settings.override_setting('privacy_policy', 'Lorem ipsum')
        self.assertTrue(settings.privacy_policy_link)
        self.assertTrue(settings.privacy_policy)

        response = self.client.get(reverse('misago:privacy-policy'))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], 'http://test.com')
开发者ID:1905410,项目名称:Misago,代码行数:10,代码来源:tests.py


示例6: test_301_on_link_tos

    def test_301_on_link_tos(self):
        """TOS view returns 302 redirect when link is set"""
        settings.override_setting('terms_of_service_link', 'http://test.com')
        settings.override_setting('terms_of_service', 'Lorem ipsum')
        self.assertTrue(settings.terms_of_service_link)
        self.assertTrue(settings.terms_of_service)

        response = self.client.get(reverse('misago:terms-of-service'))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], 'http://test.com')
开发者ID:1905410,项目名称:Misago,代码行数:10,代码来源:tests.py


示例7: test_200_on_link_tos

    def test_200_on_link_tos(self):
        """TOS view returns 200 when custom tos content is set"""
        settings.override_setting('terms_of_service_title', 'Test ToS')
        settings.override_setting('terms_of_service', 'Lorem ipsum dolor')
        self.assertTrue(settings.terms_of_service_title)
        self.assertTrue(settings.terms_of_service)

        response = self.client.get(reverse('misago:terms-of-service'))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Test ToS')
        self.assertContains(response, 'Lorem ipsum dolor')
开发者ID:1905410,项目名称:Misago,代码行数:11,代码来源:tests.py


示例8: test_api_get_question

    def test_api_get_question(self):
        """qa api returns valid QA question"""
        settings.override_setting('qa_question', 'Do you like pies?')
        settings.override_setting('qa_help_text', 'Type in "yes".')

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)

        response_json = json.loads(smart_str(response.content))
        self.assertEqual(response_json['question'], 'Do you like pies?')
        self.assertEqual(response_json['help_text'], 'Type in "yes".')
开发者ID:1905410,项目名称:Misago,代码行数:11,代码来源:test_captcha_api.py


示例9: test_api_get_question

    def test_api_get_question(self):
        """qa api returns valid QA question"""
        settings.override_setting("qa_question", "Do you like pies?")
        settings.override_setting("qa_help_text", 'Type in "yes".')

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)

        response_json = json.loads(response.content)
        self.assertEqual(response_json["question"], "Do you like pies?")
        self.assertEqual(response_json["help_text"], 'Type in "yes".')
开发者ID:ZerGabriel,项目名称:Misago,代码行数:11,代码来源:test_captcha_api.py


示例10: test_200_on_link_policy

    def test_200_on_link_policy(self):
        """policy view returns 200 when custom tos content is set"""
        settings.override_setting('privacy_policy_title', 'Test Policy')
        settings.override_setting('privacy_policy', 'Lorem ipsum dolor')
        self.assertTrue(settings.privacy_policy_title)
        self.assertTrue(settings.privacy_policy)

        response = self.client.get(reverse('misago:privacy-policy'))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Test Policy')
        self.assertContains(response, 'Lorem ipsum dolor')
开发者ID:1905410,项目名称:Misago,代码行数:11,代码来源:tests.py


示例11: test_register_decorator_calls_valid_view_200

    def test_register_decorator_calls_valid_view_200(self):
        """register decorator calls valid view"""
        settings.override_setting("account_activation", "disabled")

        response = self.client.get(reverse("misago:register"))
        self.assertEqual(response.status_code, 200)
        self.assertIn("new registrations are not currently accepted", response.content)

        settings.override_setting("account_activation", "none")
        response = self.client.get(reverse("misago:register"))
        self.assertEqual(response.status_code, 200)
        self.assertIn("Register new account", response.content)
开发者ID:sun5495,项目名称:Misago,代码行数:12,代码来源:test_registration_views.py


示例12: test_terms_of_service_responses

    def test_terms_of_service_responses(self):
        """/legal-pages/terms-of-policy/ returns valid json"""
        settings.override_setting(
            'terms_of_service_link', 'http://somewhere.com')
        settings.override_setting('terms_of_service', 'I am Bob Boberson!')

        response = self.client.get(reverse('misago:api:legal_page', kwargs={
            'page': 'terms-of-service'
        }))
        self.assertEqual(response.status_code, 200)

        data = json.loads(response.content)
        self.assertEqual(data['id'], 'terms-of-service')
        self.assertEqual(data['link'], 'http://somewhere.com')
        self.assertEqual(data['body'], '<p>I am Bob Boberson!</p>')
开发者ID:Backenkoehler,项目名称:Misago,代码行数:15,代码来源:tests.py


示例13: test_context_processor_remote_tos

    def test_context_processor_remote_tos(self):
        """context processor has TOS link to remote url"""
        settings.override_setting('terms_of_service_link', 'http://test.com')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'TERMS_OF_SERVICE_URL': 'http://test.com'
        })

        # set misago view too
        settings.override_setting('terms_of_service', 'Lorem ipsum')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'TERMS_OF_SERVICE_URL': 'http://test.com'
        })
开发者ID:1905410,项目名称:Misago,代码行数:16,代码来源:tests.py


示例14: test_context_processor_remote_policy

    def test_context_processor_remote_policy(self):
        """context processor has TOS link to remote url"""
        settings.override_setting('privacy_policy_link', 'http://test.com')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'PRIVACY_POLICY_URL': 'http://test.com'
        })

        # set misago view too
        settings.override_setting('privacy_policy', 'Lorem ipsum')
        context_dict = legal_links(MockRequest())

        self.assertEqual(context_dict, {
            'PRIVACY_POLICY_URL': 'http://test.com'
        })
开发者ID:1905410,项目名称:Misago,代码行数:16,代码来源:tests.py


示例15: test_register_view_post_creates_admin_activated_user

    def test_register_view_post_creates_admin_activated_user(self):
        """register view creates admin activated user on POST"""
        settings.override_setting("account_activation", "admin")

        response = self.client.post(
            reverse("misago:register"), data={"username": "Bob", "email": "[email protected]", "password": "pass123"}
        )
        self.assertEqual(response.status_code, 302)

        response = self.client.get(reverse("misago:register_completed"))
        self.assertIn("administrator", response.content)

        User = get_user_model()
        User.objects.get_by_username("Bob")
        User.objects.get_by_email("[email protected]")

        self.assertIn("Welcome", mail.outbox[0].subject)
开发者ID:sun5495,项目名称:Misago,代码行数:17,代码来源:test_registration_views.py


示例16: test_registration_creates_admin_activated_user

    def test_registration_creates_admin_activated_user(self):
        """api creates admin activated user on POST"""
        settings.override_setting('account_activation', 'admin')

        response = self.client.post('/api/users/',
                                    data={'username': 'Bob',
                                          'email': '[email protected]',
                                          'password': 'pass123'})

        self.assertEqual(response.status_code, 200)
        self.assertIn('admin', response.content)
        self.assertIn('Bob', response.content)
        self.assertIn('[email protected]', response.content)

        User = get_user_model()
        User.objects.get_by_username('Bob')
        User.objects.get_by_email('[email protected]')

        self.assertIn('Welcome', mail.outbox[0].subject)
开发者ID:h094071,项目名称:Misago,代码行数:19,代码来源:test_user_create_api.py


示例17: test_404_responses

    def test_404_responses(self):
        """/legal-pages/ api returns 404 for unset pages"""
        settings.override_setting('privacy_policy_link', '')
        settings.override_setting('privacy_policy', '')
        settings.override_setting('terms_of_service_link', '')
        settings.override_setting('terms_of_service', '')

        response = self.client.get(reverse('misago:api:legal_page', kwargs={
            'page': 'privacy-policy'
        }))
        self.assertEqual(response.status_code, 404)

        response = self.client.get(reverse('misago:api:legal_page', kwargs={
            'page': 'terms-of-service'
        }))
        self.assertEqual(response.status_code, 404)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:16,代码来源:tests.py


示例18: test_registration_creates_active_user

    def test_registration_creates_active_user(self):
        """api creates active and signed in user on POST"""
        settings.override_setting('account_activation', 'none')

        response = self.client.post('/api/users/',
                                    data={'username': 'Bob',
                                          'email': '[email protected]',
                                          'password': 'pass123'})

        self.assertEqual(response.status_code, 200)
        self.assertIn('active', response.content)
        self.assertIn('Bob', response.content)
        self.assertIn('[email protected]', response.content)

        User = get_user_model()
        User.objects.get_by_username('Bob')

        test_user = User.objects.get_by_email('[email protected]')
        self.assertEqual(Online.objects.filter(user=test_user).count(), 1)

        response = self.client.get(reverse('misago:index'))
        self.assertIn('Bob', response.content)

        self.assertIn('Welcome', mail.outbox[0].subject)
开发者ID:h094071,项目名称:Misago,代码行数:24,代码来源:test_user_create_api.py


示例19: test_api_invalid_qa_id

    def test_api_invalid_qa_id(self):
        """qa api returns QA question only for ID #1"""
        settings.override_setting('qa_question', 'Do you like pies?')

        response = self.client.get(self.api_link.replace('1', '24'))
        self.assertEqual(response.status_code, 404)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:6,代码来源:test_captcha_api.py


示例20: test_api_no_qa_is_set

    def test_api_no_qa_is_set(self):
        """qa api returns 404 if no QA question is set"""
        settings.override_setting('qa_question', '')

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 404)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:6,代码来源:test_captcha_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shortcuts.get_int_or_404函数代码示例发布时间:2022-05-27
下一篇:
Python errors.error404函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap