test_collect_project_platforms.py 1.2 KB

12345678910111213141516171819202122232425
  1. from django.utils import timezone
  2. from sentry.models import ProjectPlatform
  3. from sentry.tasks.collect_project_platforms import collect_project_platforms
  4. from sentry.testutils.cases import TestCase
  5. from sentry.testutils.silo import region_silo_test
  6. @region_silo_test
  7. class CollectProjectPlatformsTest(TestCase):
  8. def test_simple(self):
  9. now = timezone.now()
  10. organization = self.create_organization(name="foo")
  11. project1 = self.create_project(organization=organization, name="foo", slug="foo")
  12. project2 = self.create_project(organization=organization, name="bar", slug="bar")
  13. self.create_group(project=project1, last_seen=now, platform="php")
  14. self.create_group(project=project1, last_seen=now, platform="perl")
  15. self.create_group(project=project2, last_seen=now, platform="python")
  16. with self.tasks():
  17. collect_project_platforms(1)
  18. assert ProjectPlatform.objects.filter(project_id=project1.id, platform="php").exists()
  19. assert ProjectPlatform.objects.filter(project_id=project1.id, platform="perl").exists()
  20. assert ProjectPlatform.objects.filter(project_id=project2.id, platform="python").exists()