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


Python Environment.get_for_organization_id方法代码示例

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


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

示例1: test_simple

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
    def test_simple(self):
        project = self.create_project()

        with pytest.raises(Environment.DoesNotExist):
            Environment.get_for_organization_id(
                project.organization_id,
                'prod',
            )

        env = Environment.get_or_create(
            project=project,
            name='prod',
        )

        assert env.name == 'prod'
        assert env.projects.first().id == project.id

        env2 = Environment.get_or_create(
            project=project,
            name='prod',
        )

        assert env2.id == env.id

        with self.assertNumQueries(0):
            assert Environment.get_for_organization_id(
                project.organization_id,
                'prod',
            ).id == env.id
开发者ID:Kayle009,项目名称:sentry,代码行数:31,代码来源:test_environment.py

示例2: validate_environment

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
    def validate_environment(self, attrs, source):
        name = attrs.get(source)
        if name is None:
            return attrs

        try:
            attrs['environment'] = Environment.get_for_organization_id(
                self.context['project'].organization_id,
                name,
            ).id
        except Environment.DoesNotExist:
            raise serializers.ValidationError(u'This environment has not been created.')

        return attrs
开发者ID:Kayle009,项目名称:sentry,代码行数:16,代码来源:rule.py

示例3: _get_environment_from_request

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
    def _get_environment_from_request(self, request, organization_id):
        if not hasattr(request, '_cached_environment'):
            environment_param = request.GET.get('environment')
            if environment_param is None:
                environment = None
            else:
                environment = Environment.get_for_organization_id(
                    name=environment_param,
                    organization_id=organization_id,
                )

            request._cached_environment = environment

        return request._cached_environment
开发者ID:Kayle009,项目名称:sentry,代码行数:16,代码来源:base.py

示例4: test_tsdb

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
    def test_tsdb(self):
        project = self.project
        manager = EventManager(self.make_event(
            fingerprint=['totally unique super duper fingerprint'],
            environment='totally unique super duper environment',
        ))
        event = manager.save(project)

        def query(model, key, **kwargs):
            return tsdb.get_sums(model, [key], event.datetime, event.datetime, **kwargs)[key]

        assert query(tsdb.models.project, project.id) == 1
        assert query(tsdb.models.group, event.group.id) == 1

        environment_id = Environment.get_for_organization_id(
            event.project.organization_id,
            'totally unique super duper environment',
        ).id
        assert query(tsdb.models.project, project.id, environment_id=environment_id) == 1
        assert query(tsdb.models.group, event.group.id, environment_id=environment_id) == 1
开发者ID:hosmelq,项目名称:sentry,代码行数:22,代码来源:test_event_manager.py

示例5: _get_event_environment

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
def _get_event_environment(event, project, cache):
    from sentry.models import Environment

    environment_name = event.get_tag('environment')

    if environment_name not in cache:
        try:
            environment = Environment.get_for_organization_id(
                project.organization_id, environment_name)
        except Environment.DoesNotExist:
            logger.warn(
                'event.environment.does_not_exist',
                extra={
                    'project_id': project.id,
                    'environment_name': environment_name,
                }
            )
            environment = Environment.get_or_create(project, environment_name)

        cache[environment_name] = environment

    return cache[environment_name]
开发者ID:yogeshmangaj,项目名称:sentry,代码行数:24,代码来源:merge.py

示例6: test_event_user

# 需要导入模块: from sentry.models import Environment [as 别名]
# 或者: from sentry.models.Environment import get_for_organization_id [as 别名]
    def test_event_user(self):
        manager = EventManager(self.make_event(
            event_id='a',
            environment='totally unique environment',
            **{'sentry.interfaces.User': {
                'id': '1',
            }}
        ))
        manager.normalize()
        with self.tasks():
            event = manager.save(self.project.id)

        environment_id = Environment.get_for_organization_id(
            event.project.organization_id,
            'totally unique environment',
        ).id

        assert tsdb.get_distinct_counts_totals(
            tsdb.models.users_affected_by_group,
            (event.group.id, ),
            event.datetime,
            event.datetime,
        ) == {
            event.group.id: 1,
        }

        assert tsdb.get_distinct_counts_totals(
            tsdb.models.users_affected_by_project,
            (event.project.id, ),
            event.datetime,
            event.datetime,
        ) == {
            event.project.id: 1,
        }

        assert tsdb.get_distinct_counts_totals(
            tsdb.models.users_affected_by_group,
            (event.group.id, ),
            event.datetime,
            event.datetime,
            environment_id=environment_id,
        ) == {
            event.group.id: 1,
        }

        assert tsdb.get_distinct_counts_totals(
            tsdb.models.users_affected_by_project,
            (event.project.id, ),
            event.datetime,
            event.datetime,
            environment_id=environment_id,
        ) == {
            event.project.id: 1,
        }

        euser = EventUser.objects.get(
            project_id=self.project.id,
            ident='1',
        )
        assert event.get_tag('sentry:user') == euser.tag_value

        # ensure event user is mapped to tags in second attempt
        manager = EventManager(
            self.make_event(
                event_id='b',
                **{'sentry.interfaces.User': {
                    'id': '1',
                    'name': 'jane',
                }}
            )
        )
        manager.normalize()
        with self.tasks():
            event = manager.save(self.project.id)

        euser = EventUser.objects.get(id=euser.id)
        assert event.get_tag('sentry:user') == euser.tag_value
        assert euser.name == 'jane'
        assert euser.ident == '1'
开发者ID:hosmelq,项目名称:sentry,代码行数:81,代码来源:test_event_manager.py


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