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


Python settings.TESTING属性代码示例

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


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

示例1: ready

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def ready(self):
        super().ready()
        """
        This magic executes modules named search_indexes in every installed app. Search indexes
        is registered this way.
        """
        if not settings.TESTING:
            # Simple way to initialize the search backend. We may change this in the future.
            if settings.SEARCH_BACKEND == "elasticsearch":
                search_backed = ElasticsearchBackend()
            elif settings.SEARCH_BACKEND == "postgres":
                search_backed = PostgresBackend()
            else:
                raise ValueError("Invalid search backend")

            search_backed.set_up()
            backend.current_backend = search_backed

            autodiscover_modules("search_indexes")
            from .signals import post_save_callback, post_delete_callback  # noqa 
开发者ID:webkom,项目名称:lego,代码行数:22,代码来源:apps.py

示例2: save_kobocat_user

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def save_kobocat_user(sender, instance, created, raw, **kwargs):
    """
    Sync auth_user table between KPI and KC, and, if the user is newly created,
    grant all KoBoCAT model-level permissions for the content types listed in
    `settings.KOBOCAT_DEFAULT_PERMISSION_CONTENT_TYPES`
    """
    if not settings.TESTING:
        KobocatUser.sync(instance)

        if created:
            # FIXME: If this fails, the next attempt results in
            #   IntegrityError: duplicate key value violates unique constraint
            #   "auth_user_username_key"
            # and decorating this function with `transaction.atomic` doesn't
            # seem to help. We should roll back the KC user creation if
            # assigning model-level permissions fails
            grant_kc_model_level_perms(instance) 
开发者ID:kobotoolbox,项目名称:kpi,代码行数:19,代码来源:signals.py

示例3: clean_description

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def clean_description(self):
        desc = self.cleaned_data['description']
        if settings.TESTING:
            check_spam = False
        else:
            akismet = Akismet(settings.AKISMET_KEY, blog="CC Search")
            check_spam = akismet.check(self.request.get_host(),
                                  user_agent=self.request.META.get('user-agent'),
                                  comment_author=self.request.user.username,
                                  comment_content=desc)
        wordfilter = Wordfilter()
        check_words = wordfilter.blacklisted(desc)
        if check_spam or check_words:
            raise forms.ValidationError("This description failed our spam or profanity check; the description has not been updated.")

        return desc 
开发者ID:cc-archive,项目名称:open-ledger,代码行数:18,代码来源:forms.py

示例4: member_post_save_webhook_cb

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def member_post_save_webhook_cb(
    sender, instance, created, raw, update_fields, **kwargs
):
    """
    Send a webhook alert when a user signs up.
    """
    if raw or not created or settings.TESTING or settings.ENV != "production":
        return

    try:
        requests.post(
            settings.ZAPIER_WEBHOOK_URL,
            json={
                "type": "member-created",
                "name": instance.name,
                "username": instance.user.username,
                "email": instance.primary_email.email,
            },
        )
    except:  # pylint: disable=bare-except
        # monitoring should never interfere with the operation of the site
        pass 
开发者ID:OpenHumans,项目名称:open-humans,代码行数:24,代码来源:signals.py

示例5: ready

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def ready(self):
        if not settings.TESTING:
            from lego.apps.events.models import Event
            from lego.apps.events.signals import event_save_callback

            post_save.connect(event_save_callback, sender=Event) 
开发者ID:webkom,项目名称:lego,代码行数:8,代码来源:apps.py

示例6: disable_on_test

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def disable_on_test(signal_handler):
    """
    Decorator that turns off signal handlers when loading fixture data and running tests.
    """

    @wraps(signal_handler)
    def wrapper(*args, **kwargs):
        if kwargs.get("raw") or settings.TESTING:
            return
        return signal_handler(*args, **kwargs)

    return wrapper 
开发者ID:webkom,项目名称:lego,代码行数:14,代码来源:events.py

示例7: save_kobocat_token

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def save_kobocat_token(sender, instance, **kwargs):
    """
    Sync AuthToken table between KPI and KC
    """
    if not settings.TESTING:
        KobocatToken.sync(instance) 
开发者ID:kobotoolbox,项目名称:kpi,代码行数:8,代码来源:signals.py

示例8: delete_kobocat_token

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def delete_kobocat_token(sender, instance, **kwargs):
    """
    Delete corresponding record from KC AuthToken table
    """
    if not settings.TESTING:
        try:
            KobocatToken.objects.get(pk=instance.pk).delete()
        except KobocatToken.DoesNotExist:
            pass 
开发者ID:kobotoolbox,项目名称:kpi,代码行数:11,代码来源:signals.py

示例9: update_search_index

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def update_search_index(sender, instance, **kwargs):
    """When an Image instance is saved, tell the search engine about it."""
    if not settings.TESTING:
        _update_search_index(instance) 
开发者ID:cc-archive,项目名称:open-ledger,代码行数:6,代码来源:signals.py

示例10: toggle_data

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def toggle_data(self, user, source, public):
        if source not in get_source_labels() and not source.startswith(
            "direct-sharing-"
        ):
            error_msg = (
                "Public sharing toggle attempted for "
                'unexpected source "{}"'.format(source)
            )
            django_messages.error(self.request, error_msg)

            if not settings.TESTING:
                raven_client.captureMessage(error_msg)
            return
        project = id_label_to_project(source)
        project_membership = DataRequestProjectMember.objects.get(
            member=user.member, project=project
        )

        participant = user.member.public_data_participant
        access, _ = PublicDataAccess.objects.get_or_create(
            participant=participant, project_membership=project_membership
        )
        access.is_public = False
        if public == "True":
            if not project.no_public_data:
                access.is_public = True
        access.save()

        if (
            project.approved
            and not ActivityFeed.objects.filter(
                member=user.member, project=project, action="publicly-shared"
            ).exists()
        ):
            event = ActivityFeed(
                member=user.member, project=project, action="publicly-shared"
            )
            event.save() 
开发者ID:OpenHumans,项目名称:open-humans,代码行数:40,代码来源:views.py

示例11: test_settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def test_settings(self):
        """
        Ensure the test settings module works as expected
        """
        from django.conf import settings
        self.assertTrue(settings.TESTING)
        self.assertEqual(settings.LOGIN_URL, "/simple/login/")
        with self.settings(UNIAUTH_LOGIN_DISPLAY_STANDARD=False):
            self.assertFalse(settings.UNIAUTH_LOGIN_DISPLAY_STANDARD) 
开发者ID:lgoodridge,项目名称:django-uniauth,代码行数:11,代码来源:test_simple.py

示例12: get

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def get(self, request, *args, **kwargs):
        image = self.get_object()
        alias = kwargs.pop('alias')
        r = kwargs.pop('r')
        opts = {
            'revision_label': r,
            'animated': 'animated' in self.request.GET,
            'insecure': 'insecure' in self.request.GET,
        }

        force = request.GET.get('force')
        if force is not None:
            image.thumbnail_invalidate()

        sync = request.GET.get('sync')
        if sync is not None:
            opts['sync'] = True

        if settings.TESTING:
            thumb = image.thumbnail_raw(alias, opts)
            if thumb:
                return redirect(thumb.url)
            return None

        url = image.thumbnail(alias, opts)
        return redirect(smart_unicode(url)) 
开发者ID:astrobin,项目名称:astrobin,代码行数:28,代码来源:image.py

示例13: call_update_in_new_process

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def call_update_in_new_process(self, enabled=not settings.TESTING):
        if enabled and self.comment.reply_content:
            for _ in xrange(knobs.FOOTER_UPDATE_ATTEMPTS):
                try:
                    subprocess.check_call(
                        ["env", "python", "/var/canvas/website/manage.py", "generate_footer", str(self.comment.id)],
                        env={'DISPLAY': ':0'}
                    )
                except subprocess.CalledProcessError:
                    continue
                break 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:13,代码来源:footer.py

示例14: member_pre_save_cb

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TESTING [as 别名]
def member_pre_save_cb(sender, instance, raw, **kwargs):
    """
    Subscribe or unsubscribe a user from Mailchimp.
    """
    if raw or settings.TESTING:
        return

    try:
        member = sender.objects.get(pk=instance.pk)
    except sender.DoesNotExist:
        pass
    else:
        if member.newsletter == instance.newsletter:
            return

    if not settings.MAILCHIMP_API_KEY:
        logger.warn(
            "User changed email preference but no Mailchimp API key "
            "has been specified, set MAILCHIMP_API_KEY."
        )

        return

    mc = mailchimp.Mailchimp(settings.MAILCHIMP_API_KEY)

    try:
        address = instance.primary_email.email
    except AttributeError:
        # We're not sure why the callback is firing an extra time, before
        # SignupView.create_account runs (when email not yet saved).
        return

    if instance.newsletter:
        try:
            mc.lists.subscribe(
                settings.MAILCHIMP_NEWSLETTER_LIST,
                {"email": address},
                double_optin=False,
                update_existing=True,
            )
        except mailchimp.ListAlreadySubscribedError:
            logger.info('"%s" was already subscribed', address)
        except (mailchimp.Error, ValueError) as e:
            logger.error("A Mailchimp error occurred: %s, %s", e.__class__, e)
    else:
        try:
            mc.lists.unsubscribe(
                settings.MAILCHIMP_NEWSLETTER_LIST,
                {"email": address},
                send_goodbye=False,
                send_notify=False,
            )
        except (mailchimp.ListNotSubscribedError, mailchimp.EmailNotExistsError):
            logger.info('"%s" was already unsubscribed', address)
        except (mailchimp.Error, ValueError) as e:
            logger.error("A Mailchimp error occurred: %s, %s", e.__class__, e) 
开发者ID:OpenHumans,项目名称:open-humans,代码行数:58,代码来源:signals.py


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