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.

36 lines
1.1 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class PauseTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(PauseTestCase, self).setUp()
  6. self.check = Check(user=self.alice, status="up")
  7. self.check.save()
  8. def test_it_pauses(self):
  9. url = "/checks/%s/pause/" % self.check.code
  10. self.client.login(username="[email protected]", password="password")
  11. r = self.client.post(url)
  12. self.assertRedirects(r, "/checks/")
  13. self.check.refresh_from_db()
  14. self.assertEqual(self.check.status, "paused")
  15. def test_it_rejects_get(self):
  16. url = "/checks/%s/pause/" % self.check.code
  17. self.client.login(username="[email protected]", password="password")
  18. r = self.client.get(url)
  19. self.assertEqual(r.status_code, 405)
  20. def test_it_allows_cross_team_access(self):
  21. self.bobs_profile.current_team = None
  22. self.bobs_profile.save()
  23. url = "/checks/%s/pause/" % self.check.code
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.post(url)
  26. self.assertRedirects(r, "/checks/")