@ -2,12 +2,7 @@ from hc.accounts.models import Project | |||||
from hc.test import BaseTestCase | from hc.test import BaseTestCase | ||||
class RemoveProjectTestCase(BaseTestCase): | |||||
def setUp(self): | |||||
super(RemoveProjectTestCase, self).setUp() | |||||
self.url = "/projects/%s/remove/" % self.project.code | |||||
class AddProjectTestCase(BaseTestCase): | |||||
def test_it_works(self): | def test_it_works(self): | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/projects/add/", {"name": "My Second Project"}) | r = self.client.post("/projects/add/", {"name": "My Second Project"}) | ||||
@ -16,10 +11,6 @@ class RemoveProjectTestCase(BaseTestCase): | |||||
self.assertRedirects(r, "/projects/%s/checks/" % p.code) | self.assertRedirects(r, "/projects/%s/checks/" % p.code) | ||||
self.assertEqual(str(p.code), p.badge_key) | self.assertEqual(str(p.code), p.badge_key) | ||||
# Alice's current project should be the just created one | |||||
self.profile.refresh_from_db() | |||||
self.assertEqual(self.profile.current_project, p) | |||||
def test_it_rejects_get(self): | def test_it_rejects_get(self): | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.get("/projects/add/") | r = self.client.get("/projects/add/") | ||||
@ -34,16 +34,12 @@ class MyChecksTestCase(BaseTestCase): | |||||
delta = timezone.now() - self.profile.last_active_date | delta = timezone.now() - self.profile.last_active_date | ||||
self.assertTrue(delta.total_seconds() < 1) | self.assertTrue(delta.total_seconds() < 1) | ||||
def test_it_updates_current_project(self): | |||||
self.profile.current_project = None | |||||
self.profile.save() | |||||
def test_it_updates_session(self): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.get(self.url) | r = self.client.get(self.url) | ||||
self.assertEqual(r.status_code, 200) | self.assertEqual(r.status_code, 200) | ||||
self.profile.refresh_from_db() | |||||
self.assertEqual(self.profile.current_project, self.project) | |||||
self.assertEqual(self.client.session["last_project_id"], self.project.id) | |||||
def test_it_checks_access(self): | def test_it_checks_access(self): | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
@ -2,9 +2,9 @@ from hc.api.models import Channel, Check | |||||
from hc.test import BaseTestCase | from hc.test import BaseTestCase | ||||
class TrabsferTestCase(BaseTestCase): | |||||
class TransferTestCase(BaseTestCase): | |||||
def setUp(self): | def setUp(self): | ||||
super(TrabsferTestCase, self).setUp() | |||||
super(TransferTestCase, self).setUp() | |||||
self.check = Check.objects.create(project=self.bobs_project) | self.check = Check.objects.create(project=self.bobs_project) | ||||
self.url = "/checks/%s/transfer/" % self.check.code | self.url = "/checks/%s/transfer/" % self.check.code | ||||
@ -15,9 +15,6 @@ class TrabsferTestCase(BaseTestCase): | |||||
self.assertContains(r, "Transfer to Another Project") | self.assertContains(r, "Transfer to Another Project") | ||||
def test_it_works(self): | def test_it_works(self): | ||||
self.bobs_profile.current_project = self.bobs_project | |||||
self.bobs_profile.save() | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
payload = {"project": self.project.code} | payload = {"project": self.project.code} | ||||
r = self.client.post(self.url, payload, follow=True) | r = self.client.post(self.url, payload, follow=True) | ||||
@ -27,10 +24,6 @@ class TrabsferTestCase(BaseTestCase): | |||||
check = Check.objects.get() | check = Check.objects.get() | ||||
self.assertEqual(check.project, self.project) | self.assertEqual(check.project, self.project) | ||||
# Bob's current project should have been updated | |||||
self.bobs_profile.refresh_from_db() | |||||
self.assertEqual(self.bobs_profile.current_project, self.project) | |||||
def test_it_obeys_check_limit(self): | def test_it_obeys_check_limit(self): | ||||
# Alice's projects cannot accept checks due to limits: | # Alice's projects cannot accept checks due to limits: | ||||
self.profile.check_limit = 0 | self.profile.check_limit = 0 | ||||