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.

39 lines
1.3 KiB

  1. from django.contrib.auth.models import User
  2. from django.test import TestCase
  3. from hc.accounts.models import Member, Profile
  4. class BaseTestCase(TestCase):
  5. def setUp(self):
  6. super(BaseTestCase, self).setUp()
  7. # Alice is a normal user for tests. Alice has team access enabled.
  8. self.alice = User(username="alice", email="[email protected]")
  9. self.alice.set_password("password")
  10. self.alice.save()
  11. self.profile = Profile(user=self.alice, api_key="abc")
  12. self.profile.team_access_allowed = True
  13. self.profile.save()
  14. # Bob is on Alice's team and should have access to her stuff
  15. self.bob = User(username="bob", email="[email protected]")
  16. self.bob.set_password("password")
  17. self.bob.save()
  18. self.bobs_profile = Profile(user=self.bob)
  19. self.bobs_profile.current_team = self.profile
  20. self.bobs_profile.save()
  21. m = Member(team=self.profile, user=self.bob)
  22. m.save()
  23. # Charlie should have no access to Alice's stuff
  24. self.charlie = User(username="charlie", email="[email protected]")
  25. self.charlie.set_password("password")
  26. self.charlie.save()
  27. charlies_profile = Profile(user=self.charlie)
  28. charlies_profile.save()