test_project_keys.py 885 B

123456789101112131415161718192021222324
  1. from django.test import TestCase
  2. from django.urls import reverse
  3. from model_bakery import baker
  4. from apps.organizations_ext.constants import OrganizationUserRole
  5. from ..models import ProjectKey
  6. class ProjectKeyAPITestCase(TestCase):
  7. def setUp(self):
  8. self.user = baker.make("users.user")
  9. self.client.force_login(self.user)
  10. self.organization = baker.make("organizations_ext.Organization")
  11. self.organization.add_user(self.user, role=OrganizationUserRole.OWNER)
  12. self.project = baker.make("projects.Project", organization=self.organization)
  13. self.url = reverse(
  14. "api:list_project_keys", args=[self.organization.slug, self.project.slug]
  15. )
  16. def test_key_dsn(self):
  17. project_key = ProjectKey.objects.get()
  18. res = self.client.get(self.url)
  19. self.assertContains(res, project_key.public_key_hex)