utils.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import json
  2. from django.test import TestCase
  3. from model_bakery import baker
  4. from glitchtip.test_utils.test_case import GlitchTipTestCaseMixin
  5. from organizations_ext.models import OrganizationUserRole
  6. class EventIngestTestCase(GlitchTipTestCaseMixin, TestCase):
  7. """
  8. Base class for event ingest tests with helper functions
  9. """
  10. def setUp(self):
  11. self.create_project()
  12. self.params = f"?sentry_key={self.projectkey.public_key}"
  13. def get_json_data(self, filename: str):
  14. with open(filename) as json_file:
  15. return json.load(json_file)
  16. def create_logged_in_user(self):
  17. self.user = baker.make("users.user")
  18. self.client.force_login(self.user)
  19. self.org_user = self.organization.add_user(
  20. self.user, OrganizationUserRole.ADMIN
  21. )
  22. self.team = baker.make("teams.Team", organization=self.organization)
  23. self.team.members.add(self.org_user)
  24. self.project = baker.make("projects.Project", organization=self.organization)
  25. self.project.team_set.add(self.team)