from django.contrib.auth.models import User
|
|
from django.test import TestCase
|
|
|
|
from hc.accounts.models import Member, Profile
|
|
|
|
|
|
class BaseTestCase(TestCase):
|
|
|
|
def setUp(self):
|
|
super(BaseTestCase, self).setUp()
|
|
|
|
# Alice is a normal user for tests
|
|
self.alice = User(username="alice", email="[email protected]")
|
|
self.alice.set_password("password")
|
|
self.alice.save()
|
|
|
|
self.profile = Profile(user=self.alice, api_key="abc")
|
|
self.profile.save()
|
|
|
|
# Bob is on Alice's team and should have access to her stuff
|
|
self.bob = User(username="bob", email="[email protected]")
|
|
self.bob.set_password("password")
|
|
self.bob.save()
|
|
|
|
self.bobs_profile = Profile(user=self.bob)
|
|
self.bobs_profile.current_team = self.profile
|
|
self.bobs_profile.save()
|
|
|
|
m = Member(team=self.profile, user=self.bob)
|
|
m.save()
|
|
|
|
# Charlie should have no access to Alice's stuff
|
|
self.charlie = User(username="charlie", email="[email protected]")
|
|
self.charlie.set_password("password")
|
|
self.charlie.save()
|
|
|
|
charlies_profile = Profile(user=self.charlie)
|
|
charlies_profile.save()
|