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.

32 lines
1.0 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class RemoveProjectTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.url = "/projects/%s/remove/" % self.project.code
  7. def test_it_works(self):
  8. Check.objects.create(project=self.project, tags="foo a-B_1 baz@")
  9. self.client.login(username="[email protected]", password="password")
  10. r = self.client.post(self.url)
  11. self.assertRedirects(r, "/")
  12. # Alice should not own any projects
  13. self.assertFalse(self.alice.project_set.exists())
  14. # Check should be gone
  15. self.assertFalse(Check.objects.exists())
  16. def test_it_rejects_get(self):
  17. self.client.login(username="[email protected]", password="password")
  18. r = self.client.get(self.url)
  19. self.assertEqual(r.status_code, 405)
  20. def test_it_checks_access(self):
  21. self.client.login(username="[email protected]", password="password")
  22. r = self.client.post(self.url)
  23. self.assertEqual(r.status_code, 404)