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


Python settings.override_setting函数代码示例

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


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


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