Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_resolved_in_next_release(self):
release = Release.objects.create(project=self.project, version='a')
group = self.create_group(
checksum='a' * 32,
status=GroupStatus.UNRESOLVED,
)
self.login_as(user=self.user)
url = '{url}?id={group.id}'.format(
url=self.path,
group=group,
)
response = self.client.put(url, data={
'status': 'resolvedInNextRelease',
}, format='json')
assert response.status_code == 200
def test_simple(self):
self.login_as(user=self.user)
org = self.create_organization(owner=self.user, name="baz")
repo = Repository.objects.create(name="example", provider="dummy", organization_id=org.id)
release = Release.objects.create(organization_id=org.id, version="abcabcabc")
commit = Commit.objects.create(organization_id=org.id, repository_id=repo.id, key="a" * 40)
ReleaseHeadCommit.objects.create(
organization_id=org.id, repository_id=repo.id, release=release, commit=commit
)
refs = [{"repository": repo.name, "commit": "b" * 40}]
release2 = Release.objects.create(organization_id=org.id, version="12345678")
deploy = Deploy.objects.create(organization_id=org.id, release=release2, environment_id=5)
with self.tasks():
with patch.object(Deploy, "notify_if_ready") as mock_notify_if_ready:
fetch_commits(
def test_notify_after_resolve_from_set_commits(self, delay):
repo = Repository.objects.create(organization_id=self.organization.id, name="test/repo")
release = Release.objects.create(version="abcabc", organization=self.organization)
commit = Commit.objects.create(
repository_id=repo.id, organization_id=self.organization.id, key="b" * 40
)
GroupLink.objects.create(
group_id=self.issue.id,
project_id=self.project.id,
linked_type=GroupLink.LinkedType.commit,
linked_id=commit.id,
)
release.add_project(self.project)
release.set_commits(
[
{
self.login_as(user=self.user)
team = self.create_team()
project1 = self.create_project(teams=[team], name="foo")
project2 = self.create_project(teams=[team], name="bar")
release1 = Release.objects.create(
organization_id=project1.organization_id,
version="1",
date_added=datetime(2013, 8, 13, 3, 8, 24, 880386),
)
release1.add_project(project1)
ReleaseProject.objects.filter(project=project1, release=release1).update(new_groups=5)
release2 = Release.objects.create(
organization_id=project1.organization_id,
version="2",
date_added=datetime(2013, 8, 14, 3, 8, 24, 880386),
)
release2.add_project(project1)
release3 = Release.objects.create(
organization_id=project1.organization_id,
version="3",
date_added=datetime(2013, 8, 12, 3, 8, 24, 880386),
date_released=datetime(2013, 8, 15, 3, 8, 24, 880386),
)
release3.add_project(project1)
release4 = Release.objects.create(organization_id=project2.organization_id, version="4")
release4.add_project(project2)
organization_id=org.id, name="example/example", provider="dummy"
)
repo2 = Repository.objects.create(
organization_id=org.id, name="example/example2", provider="dummy"
)
team1 = self.create_team(organization=org)
team2 = self.create_team(organization=org)
project = self.create_project(teams=[team1], organization=org)
project2 = self.create_project(teams=[team2], organization=org)
base_release = Release.objects.create(organization_id=org.id, version="000000000")
base_release.add_project(project)
release = Release.objects.create(organization_id=org.id, version="abcabcabc")
release2 = Release.objects.create(organization_id=org.id, version="12345678")
release.add_project(project)
release2.add_project(project2)
self.create_member(teams=[team1], user=user, organization=org)
self.login_as(user=user)
url = reverse(
"sentry-api-0-organization-release-details",
kwargs={"organization_slug": org.slug, "version": base_release.version},
)
self.client.put(
url,
{
"ref": "master",
def test_activity_generation_long_version(self):
self.login_as(user=self.user)
project = self.create_project(name="foo")
project2 = self.create_project(name="bar", organization=project.organization)
release = Release.objects.create(organization_id=project.organization_id, version="x" * 65)
release.add_project(project)
release.add_project(project2)
url = reverse(
"sentry-api-0-project-release-details",
kwargs={
"organization_slug": project.organization.slug,
"project_slug": project.slug,
"version": release.version,
},
)
response = self.client.put(url, data={"dateReleased": datetime.utcnow().isoformat() + "Z"})
assert response.status_code == 200, (response.status_code, response.content)
release = Release.objects.get(id=release.id)
def test_update_release(self):
project = self.create_project()
version = "bbee5b51f84611e4b14834363b8514c2"
r = Release.objects.create(organization_id=project.organization_id, version=version)
r.add_project(project)
hook = ReleaseHook(project)
hook.start_release(version)
release = Release.objects.get(
organization_id=project.organization_id, projects=project, version=version
)
assert release.organization == project.organization
def test_simple(self, mock_delay):
release = Release.objects.create(version="a", organization_id=self.project.organization_id)
release.add_project(self.project)
mock_delay.assert_called_once_with(release_id=release.id)
def test_no_commits_no_head_commits(self):
# case where there are not commits, but also no head commit,
# so we shouldn't bother waiting to notify
org = self.create_organization()
project = self.create_project(organization=org)
release = Release.objects.create(version="a" * 40, organization=org)
release.add_project(project)
env = Environment.objects.create(name="production", organization_id=org.id)
deploy = Deploy.objects.create(
release=release, organization_id=org.id, environment_id=env.id
)
Deploy.notify_if_ready(deploy.id)
# make sure activity has been created
assert Activity.objects.filter(
type=Activity.DEPLOY, project=project, ident=release.version
).exists()
assert (
Activity.objects.get(type=Activity.DEPLOY, project=project, ident=release.version).data[
"deploy_id"
team1 = self.create_team(organization=org)
team2 = self.create_team(organization=org)
project1 = self.create_project(teams=[team1], organization=org)
project2 = self.create_project(teams=[team2], organization=org)
self.create_member(teams=[team1], user=user, organization=org)
self.login_as(user=user)
release1 = Release.objects.create(
organization_id=org.id, version="1", date_added=datetime(2013, 8, 13, 3, 8, 24, 880386)
)
release1.add_project(project1)
release2 = Release.objects.create(
organization_id=org.id, version="2", date_added=datetime(2013, 8, 14, 3, 8, 24, 880386)
)
release2.add_project(project2)
release3 = Release.objects.create(
organization_id=org.id,
version="3",
date_added=datetime(2013, 8, 12, 3, 8, 24, 880386),
date_released=datetime(2013, 8, 15, 3, 8, 24, 880386),
)
release3.add_project(project1)
url = reverse("sentry-api-0-organization-releases", kwargs={"organization_slug": org.slug})
response = self.client.post(
url, data={"version": "1.2.1", "projects": [project1.slug, project2.slug]}
)