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.2 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. assert Check.objects.count() == 1
  10. def test_team_access_works(self):
  11. url = "/checks/add/"
  12. self.client.login(username="[email protected]", password="password")
  13. self.client.post(url)
  14. check = Check.objects.get()
  15. # Added by bob, but should belong to alice (bob has team access)
  16. self.assertEqual(check.user, self.alice)
  17. def test_it_rejects_get(self):
  18. url = "/checks/add/"
  19. self.client.login(username="[email protected]", password="password")
  20. r = self.client.get(url)
  21. self.assertEqual(r.status_code, 405)
  22. def test_it_obeys_check_limit(self):
  23. self.profile.check_limit = 0
  24. self.profile.save()
  25. url = "/checks/add/"
  26. self.client.login(username="[email protected]", password="password")
  27. r = self.client.post(url)
  28. self.assertEqual(r.status_code, 400)