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 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. Member.objects.create(team=self.profile, user=self.bob)
  22. # Charlie should have no access to Alice's stuff
  23. self.charlie = User(username="charlie", email="[email protected]")
  24. self.charlie.set_password("password")
  25. self.charlie.save()
  26. Profile.objects.create(user=self.charlie)