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.

37 lines
1.2 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class RemoveProjectTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(RemoveProjectTestCase, self).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's current project should be not set
  13. self.profile.refresh_from_db()
  14. self.assertEqual(self.profile.current_project, None)
  15. # Alice should not own any projects
  16. self.assertFalse(self.alice.project_set.exists())
  17. # Check should be gone
  18. self.assertFalse(Check.objects.exists())
  19. def test_it_rejects_get(self):
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get(self.url)
  22. self.assertEqual(r.status_code, 405)
  23. def test_it_checks_access(self):
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.post(self.url)
  26. self.assertEqual(r.status_code, 404)