You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

  1. from hc.test import BaseTestCase
  2. from hc.api.models import Check
  3. class BadgesTestCase(BaseTestCase):
  4. def test_it_shows_badges(self):
  5. Check.objects.create(project=self.project, tags="foo a-B_1 baz@")
  6. Check.objects.create(project=self.bobs_project, tags="bobs-tag")
  7. self.client.login(username="[email protected]", password="password")
  8. r = self.client.get("/projects/%s/badges/" % self.project.code)
  9. self.assertContains(r, "foo.svg")
  10. self.assertContains(r, "a-B_1.svg")
  11. # Expect badge URLs only for tags that match \w+
  12. self.assertNotContains(r, "[email protected]")
  13. # Expect only Alice's tags
  14. self.assertNotContains(r, "bobs-tag.svg")
  15. def test_it_uses_badge_key(self):
  16. Check.objects.create(project=self.project, tags="foo bar")
  17. Check.objects.create(project=self.bobs_project, tags="bobs-tag")
  18. self.project.badge_key = "alices-badge-key"
  19. self.project.save()
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get("/projects/%s/badges/" % self.project.code)
  22. self.assertContains(r, "badge/alices-badge-key/")
  23. self.assertContains(r, "badge/alices-badge-key/")