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.

38 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.sms_limit = 50
  14. self.profile.save()
  15. # Bob is on Alice's team and should have access to her stuff
  16. self.bob = User(username="bob", email="[email protected]")
  17. self.bob.set_password("password")
  18. self.bob.save()
  19. self.bobs_profile = Profile(user=self.bob)
  20. self.bobs_profile.current_team = self.profile
  21. self.bobs_profile.save()
  22. Member.objects.create(team=self.profile, user=self.bob)
  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. Profile.objects.create(user=self.charlie)