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.

48 lines
1.6 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class AddCheckTestCase(BaseTestCase):
  4. def test_it_works(self):
  5. url = "/checks/add/"
  6. self.client.login(username="[email protected]", password="password")
  7. r = self.client.post(url)
  8. self.assertRedirects(r, "/checks/")
  9. check = Check.objects.get()
  10. self.assertEqual(check.project, self.project)
  11. def test_it_handles_unset_current_project(self):
  12. self.profile.current_project = None
  13. self.profile.save()
  14. url = "/checks/add/"
  15. self.client.login(username="[email protected]", password="password")
  16. r = self.client.post(url)
  17. self.assertRedirects(r, "/checks/")
  18. check = Check.objects.get()
  19. self.assertEqual(check.project, self.project)
  20. def test_team_access_works(self):
  21. url = "/checks/add/"
  22. self.client.login(username="[email protected]", password="password")
  23. self.client.post(url)
  24. check = Check.objects.get()
  25. # Added by bob, but should belong to alice (bob has team access)
  26. self.assertEqual(check.user, self.alice)
  27. def test_it_rejects_get(self):
  28. url = "/checks/add/"
  29. self.client.login(username="[email protected]", password="password")
  30. r = self.client.get(url)
  31. self.assertEqual(r.status_code, 405)
  32. def test_it_obeys_check_limit(self):
  33. self.profile.check_limit = 0
  34. self.profile.save()
  35. url = "/checks/add/"
  36. self.client.login(username="[email protected]", password="password")
  37. r = self.client.post(url)
  38. self.assertEqual(r.status_code, 400)