test_project_keys.py 992 B

123456789101112131415161718192021222324
  1. from django.shortcuts import reverse
  2. from rest_framework.test import APITestCase
  3. from model_bakery import baker
  4. from glitchtip import test_utils # pylint: disable=unused-import
  5. from organizations_ext.models import OrganizationUserRole
  6. from ..models import ProjectKey
  7. class ProjectKeyAPITestCase(APITestCase):
  8. def setUp(self):
  9. self.user = baker.make("users.user")
  10. self.client.force_login(self.user)
  11. self.organization = baker.make("organizations_ext.Organization")
  12. self.organization.add_user(self.user, role=OrganizationUserRole.OWNER)
  13. self.project = baker.make("projects.Project", organization=self.organization)
  14. self.url = reverse(
  15. "project-keys-list",
  16. kwargs={"project_pk": self.organization.slug + "/" + self.project.slug},
  17. )
  18. def test_key_dsn(self):
  19. project_key = ProjectKey.objects.get()
  20. res = self.client.get(self.url)
  21. self.assertContains(res, project_key.public_key_hex)