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.

23 lines
849 B

  1. from hc.test import BaseTestCase
  2. from hc.accounts.models import Project
  3. from hc.api.models import Check, Channel
  4. class ProjectModelTestCase(BaseTestCase):
  5. def test_num_checks_available_handles_multiple_projects(self):
  6. # One check in Alice's primary project:
  7. Check.objects.create(project=self.project)
  8. # One check in Alice's secondary project:
  9. p2 = Project.objects.create(owner=self.alice)
  10. Check.objects.create(project=p2)
  11. self.assertEqual(self.project.num_checks_available(), 18)
  12. def test_it_handles_zero_broken_channels(self):
  13. self.assertFalse(self.project.have_broken_channels())
  14. def test_it_handles_one_broken_channel(self):
  15. Channel.objects.create(kind="webhook", last_error="x", project=self.project)
  16. self.assertTrue(self.project.have_broken_channels())