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.0 KiB

  1. from django.contrib.auth.models import User
  2. from hc.test import BaseTestCase
  3. from hc.accounts.models import Member, Profile
  4. class SwitchTeamTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(SwitchTeamTestCase, self).setUp()
  7. self.bob = User(username="bob", email="[email protected]")
  8. self.bob.set_password("password")
  9. self.bob.save()
  10. bobs_profile = Profile(user=self.bob)
  11. bobs_profile.save()
  12. m = Member(team=bobs_profile, user=self.alice)
  13. m.save()
  14. def test_it_switches(self):
  15. self.client.login(username="[email protected]", password="password")
  16. url = "/accounts/switch_team/%s/" % self.bob.username
  17. r = self.client.get(url, follow=True)
  18. self.assertContains(r, "[email protected]")
  19. def test_it_checks_team_membership(self):
  20. self.client.login(username="[email protected]", password="password")
  21. url = "/accounts/switch_team/%s/" % self.bob.username
  22. r = self.client.get(url)
  23. self.assertEqual(r.status_code, 403)