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.3 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class ResumeTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.check = Check.objects.create(project=self.project, status="paused")
  7. self.url = "/checks/%s/resume/" % self.check.code
  8. self.redirect_url = "/checks/%s/details/" % self.check.code
  9. def test_it_resumes(self):
  10. self.client.login(username="[email protected]", password="password")
  11. r = self.client.post(self.url)
  12. self.assertRedirects(r, self.redirect_url)
  13. self.check.refresh_from_db()
  14. self.assertEqual(self.check.status, "new")
  15. def test_it_rejects_get(self):
  16. self.client.login(username="[email protected]", password="password")
  17. r = self.client.get(self.url)
  18. self.assertEqual(r.status_code, 405)
  19. def test_it_allows_cross_team_access(self):
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.post(self.url)
  22. self.assertRedirects(r, self.redirect_url)
  23. def test_it_requires_rw_access(self):
  24. self.bobs_membership.rw = False
  25. self.bobs_membership.save()
  26. self.client.login(username="[email protected]", password="password")
  27. r = self.client.post(self.url)
  28. self.assertEqual(r.status_code, 403)