Skip to content

Commit e726126

Browse files
committed
add a test that access time bumps are working
1 parent 2d2167b commit e726126

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/sentry/api/endpoints/test_project_artifact_lookup.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,50 @@ def test_renewal_with_url(self):
596596
== expected_date_added
597597
)
598598

599+
def test_renewal_of_releasefiles(self):
600+
old_timestamp = datetime.now(tz=timezone.utc) - timedelta(days=45)
601+
602+
file_headers = {"Sourcemap": "application.js.map"}
603+
file = make_file("application.js", b"wat", "release.file", file_headers)
604+
releasefile = ReleaseFile.objects.create(
605+
organization_id=self.project.organization_id,
606+
release_id=self.release.id,
607+
file=file,
608+
name="http://example.com/application.js",
609+
date_accessed=old_timestamp,
610+
)
611+
612+
archive1, archive1_file = self.create_archive(
613+
fields={},
614+
files={
615+
"foo": "foo1",
616+
"bar": "bar1",
617+
},
618+
)
619+
archive1.date_accessed = old_timestamp
620+
archive1.save()
621+
622+
self.login_as(user=self.user)
623+
624+
url = reverse(
625+
"sentry-api-0-project-artifact-lookup",
626+
kwargs={
627+
"organization_id_or_slug": self.project.organization.slug,
628+
"project_id_or_slug": self.project.slug,
629+
},
630+
)
631+
632+
response = self.client.get(
633+
f"{url}?release={self.release.version}&url=application.js"
634+
).json()
635+
636+
# the lookup finds both, as the bundle is resolved only by the release
637+
assert len(response) == 2
638+
assert response[0]["type"] == "file"
639+
assert response[1]["type"] == "bundle"
640+
assert ReleaseFile.objects.get(id=releasefile.id).date_accessed > old_timestamp
641+
assert ReleaseFile.objects.get(id=archive1.id).date_accessed > old_timestamp
642+
599643
def test_access_control(self):
600644
# release file
601645
file_a = make_file("application.js", b"wat", "release.file", {})

0 commit comments

Comments
 (0)