How to use sentry - 10 common examples

To help you get started, we’ve selected a few sentry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NetEaseGame / Sentry / tests / sentry / api / endpoints / test_project_details.py View on Github external
url = reverse('sentry-api-0-project-details', kwargs={
            'organization_slug': project.organization.slug,
            'project_slug': project.slug,
        })
        options = {
            'sentry:origins': 'foo\nbar',
            'sentry:resolve_age': 1,
            'sentry:scrub_data': False,
            'sentry:scrub_defaults': False,
            'sentry:sensitive_fields': ['foo', 'bar']
        }
        resp = self.client.put(url, data={
            'options': options
        })
        assert resp.status_code == 200, resp.content
        project = Project.objects.get(id=project.id)
        assert project.get_option('sentry:origins', []) == options['sentry:origins'].split('\n')
        assert project.get_option('sentry:resolve_age', 0) == options['sentry:resolve_age']
        assert project.get_option('sentry:scrub_data', True) == options['sentry:scrub_data']
        assert project.get_option('sentry:scrub_defaults', True) == options['sentry:scrub_defaults']
        assert project.get_option('sentry:sensitive_fields', []) == options['sentry:sensitive_fields']
github getsentry / sentry / tests / sentry / test_culprit.py View on Github external
def get_culprit(data):
    mgr = EventManager(data)
    mgr.normalize()
    return mgr.get_culprit()
github getsentry / sentry / tests / sentry / receivers / test_releases.py View on Github external
def assertResolvedFromCommit(self, group, commit):
        assert GroupLink.objects.filter(
            group_id=group.id, linked_type=GroupLink.LinkedType.commit, linked_id=commit.id
        ).exists()
        assert Group.objects.filter(
            id=group.id, status=GroupStatus.RESOLVED, resolved_at__isnull=False
        ).exists()
github getsentry / sentry / tests / sentry / web / frontend / test_organization_member_settings.py View on Github external
def test_member_cant_edit(self):
        organization = self.create_organization(name='foo', owner=self.user)
        member = self.create_user('foo@example.com', is_superuser=False)
        owner_om = OrganizationMember.objects.get(
            organization=organization,
            user=self.user,
        )

        OrganizationMember.objects.create(
            organization=organization,
            user=member,
            role='member',
        )

        path = reverse('sentry-organization-member-settings',
                       args=[organization.slug, owner_om.id])

        self.login_as(member)

        resp = self.client.get(path)
github getsentry / sentry / tests / sentry / lang / javascript / test_sourcemaps.py View on Github external
src_id=1,
                name='captureException'
            ),
            SourceMapTokenMatch(
                dst_line=0,
                dst_col=191,
                src='foo/file2.js',
                src_line=9,
                src_col=25,
                src_id=1,
                name='e'
            ),
        ]


class ParseIndexedSourcemapTest(TestCase):
    # Tests lookups that fall exactly on source map token boundaries
    # https://github.com/mozilla/source-map/blob/master/test/test-source-map-consumer.js#138
    def test_exact_mappings(self):
        smap_view = SourceMapView.from_json_bytes(indexed_sourcemap_example)

        # one.js
        assert smap_view.lookup(0, 1) == SourceMapTokenMatch(
            dst_line=0,
            dst_col=1,
            src='/the/root/one.js',
            src_line=0,
            src_col=1,
            src_id=0,
            name=None
        )
        assert smap_view.lookup(0, 18) == SourceMapTokenMatch(
github getsentry / sentry / tests / sentry / models / test_pullrequest.py View on Github external
from __future__ import absolute_import

from hashlib import sha1
from uuid import uuid4

from sentry.models import Commit, Repository, PullRequest
from sentry.testutils import TestCase


class FindReferencedGroupsTest(TestCase):
    def test_multiple_matches_basic(self):
        group = self.create_group()
        group2 = self.create_group()

        repo = Repository.objects.create(name="example", organization_id=self.group.organization.id)

        commit = Commit.objects.create(
            key=sha1(uuid4().hex).hexdigest(),
            repository_id=repo.id,
            organization_id=group.organization.id,
            message=u"Foo Biz\n\nFixes {}".format(group.qualified_short_id),
        )

        groups = commit.find_referenced_groups()
        assert len(groups) == 1
        assert group in groups
github getsentry / sentry / tests / sentry / integrations / slack / test_link_identity.py View on Github external
import responses

from mock import patch

from sentry.models import (
    Identity,
    IdentityProvider,
    IdentityStatus,
    Integration,
    OrganizationIntegration,
)
from sentry.testutils import TestCase
from sentry.integrations.slack.link_identity import build_linking_url


class SlackIntegrationLinkIdentityTest(TestCase):
    def setUp(self):
        super(TestCase, self).setUp()
        self.user1 = self.create_user(is_superuser=False)
        self.user2 = self.create_user(is_superuser=False)
        self.org = self.create_organization(owner=None)
        self.team = self.create_team(organization=self.org, members=[self.user1, self.user2])

        self.login_as(self.user1)

        self.integration = Integration.objects.create(
            provider="slack",
            external_id="TXXXXXXX1",
            metadata={"access_token": "xoxa-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx"},
        )
        OrganizationIntegration.objects.create(organization=self.org, integration=self.integration)
github NetEaseGame / Sentry / tests / sentry / utils / queue / tests.py View on Github external
from __future__ import absolute_import

from sentry.utils.queue import can_queue
from sentry.testutils import TestCase


def test_func():
    pass


class CanQueueTest(TestCase):
    def test_disabled(self):
        with self.Settings(SENTRY_USE_QUEUE=False):
            self.assertFalse(can_queue(test_func))

    def test_empty_whitelist(self):
        with self.Settings(SENTRY_USE_QUEUE=()):
            self.assertFalse(can_queue(test_func))

    def test_enabled(self):
        with self.Settings(SENTRY_USE_QUEUE=True):
            self.assertTrue(can_queue(test_func))

    def test_in_whitelist(self):
        with self.Settings(SENTRY_USE_QUEUE=('%s.test_func' % (__name__,))):
            self.assertTrue(can_queue(test_func))
github NetEaseGame / Sentry / tests / sentry / utils / email / tests.py View on Github external
from __future__ import absolute_import

from mock import patch

from django.core import mail

from sentry.models import User, UserOption, GroupEmailThread
from sentry.testutils import TestCase
from sentry.utils.email import MessageBuilder


class MessageBuilderTest(TestCase):
    def test_raw_content(self):
        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<b>hello world</b>',
            headers={'X-Test': 'foo'},
        )
        msg.send(['foo@example.com'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['foo@example.com']
        assert out.subject == 'Test'
        assert out.extra_headers['X-Test'] == 'foo'
        assert out.body == 'hello world'
github NetEaseGame / Sentry / tests / sentry / web / frontend / projects / tests.py View on Github external
def test_requires_authentication(self):
        self.assertRequiresAuthentication(self.path, 'POST')

    def test_does_not_respond_to_get(self):
        resp = self.client.get(self.path)
        assert resp.status_code == 405

    def test_removes_key_and_redirects(self):
        self.login_as(self.user)

        resp = self.client.post(self.path)
        assert resp.status_code == 302
        assert not ProjectKey.objects.filter(id=self.key.id).exists()


class EnableProjectKeyTest(TestCase):
    def setUp(self):
        super(EnableProjectKeyTest, self).setUp()
        self.key = ProjectKey.objects.create(
            project=self.project,
            status=ProjectKeyStatus.INACTIVE,
        )

    @fixture
    def path(self):
        return reverse('sentry-enable-project-key', args=[self.organization.slug, self.project.id, self.key.id])

    def test_requires_authentication(self):
        self.assertRequiresAuthentication(self.path, 'POST')

    def test_does_not_respond_to_get(self):
        resp = self.client.get(self.path)