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.

41 lines
1.4 KiB

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