test_dsyms.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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={"organization_slug": self.organization.slug, "project_slug": self.project.slug},
  12. )
  13. self.create_dif_file(project=self.project)
  14. self.login_as(user=self.user)
  15. def test_get(self):
  16. response = self.client.get(self.url)
  17. request = RequestFactory().get(self.url)
  18. self.validate_schema(request, response)
  19. def test_post(self):
  20. PROGUARD_UUID = "6dc7fdb0-d2fb-4c8e-9d6b-bb1aa98929b1"
  21. PROGUARD_SOURCE = b"""\
  22. org.slf4j.helpers.Util$ClassContextSecurityManager -> org.a.b.g$a:
  23. 65:65:void <init>() -> <init>
  24. 67:67:java.lang.Class[] getClassContext() -> getClassContext
  25. 65:65:void <init>(org.slf4j.helpers.Util$1) -> <init>
  26. """
  27. out = BytesIO()
  28. f = zipfile.ZipFile(out, "w")
  29. f.writestr("proguard/%s.txt" % PROGUARD_UUID, PROGUARD_SOURCE)
  30. f.close()
  31. data = {
  32. "file": SimpleUploadedFile(
  33. "symbols.zip", out.getvalue(), content_type="application/zip"
  34. ),
  35. }
  36. response = self.client.post(
  37. self.url,
  38. data,
  39. format="multipart",
  40. )
  41. request = RequestFactory().post(self.url, data)
  42. self.validate_schema(request, response)