test_dsyms.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import zipfile
  2. from io import BytesIO
  3. from django.core.files.uploadedfile import SimpleUploadedFile
  4. from django.test.client import RequestFactory
  5. from django.urls import reverse
  6. from fixtures.apidocs_test_case import APIDocsTestCase
  7. class ProjectDsymsDocs(APIDocsTestCase):
  8. def setUp(self):
  9. self.url = reverse(
  10. "sentry-api-0-dsym-files",
  11. kwargs={
  12. "organization_slug": self.organization.slug,
  13. "project_id_or_slug": self.project.slug,
  14. },
  15. )
  16. self.create_dif_file(project=self.project)
  17. self.login_as(user=self.user)
  18. def test_get(self):
  19. response = self.client.get(self.url)
  20. request = RequestFactory().get(self.url)
  21. self.validate_schema(request, response)
  22. def test_post(self):
  23. PROGUARD_UUID = "6dc7fdb0-d2fb-4c8e-9d6b-bb1aa98929b1"
  24. PROGUARD_SOURCE = b"""\
  25. org.slf4j.helpers.Util$ClassContextSecurityManager -> org.a.b.g$a:
  26. 65:65:void <init>() -> <init>
  27. 67:67:java.lang.Class[] getClassContext() -> getClassContext
  28. 65:65:void <init>(org.slf4j.helpers.Util$1) -> <init>
  29. """
  30. out = BytesIO()
  31. f = zipfile.ZipFile(out, "w")
  32. f.writestr("proguard/%s.txt" % PROGUARD_UUID, PROGUARD_SOURCE)
  33. f.close()
  34. data = {
  35. "file": SimpleUploadedFile(
  36. "symbols.zip", out.getvalue(), content_type="application/zip"
  37. ),
  38. }
  39. response = self.client.post(
  40. self.url,
  41. data,
  42. format="multipart",
  43. )
  44. request = RequestFactory().post(self.url, data)
  45. self.validate_schema(request, response)