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.

53 lines
1.9 KiB

  1. from django.contrib.auth.models import User
  2. from django.test import TestCase
  3. from hc.accounts.models import Member, Profile, Project
  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.project = Project(owner=self.alice, api_key="X" * 32)
  12. self.project.name = "Alice's Project"
  13. self.project.badge_key = self.alice.username
  14. self.project.save()
  15. self.profile = Profile(user=self.alice)
  16. self.profile.sms_limit = 50
  17. self.profile.save()
  18. # Bob is on Alice's team and should have access to her stuff
  19. self.bob = User(username="bob", email="[email protected]")
  20. self.bob.set_password("password")
  21. self.bob.save()
  22. self.bobs_project = Project(owner=self.bob)
  23. self.bobs_project.badge_key = self.bob.username
  24. self.bobs_project.save()
  25. self.bobs_profile = Profile(user=self.bob)
  26. self.bobs_profile.current_project = self.project
  27. self.bobs_profile.save()
  28. Member.objects.create(user=self.bob, project=self.project)
  29. # Charlie should have no access to Alice's stuff
  30. self.charlie = User(username="charlie", email="[email protected]")
  31. self.charlie.set_password("password")
  32. self.charlie.save()
  33. self.charlies_project = Project(owner=self.charlie)
  34. self.charlies_project.badge_key = self.charlie.username
  35. self.charlies_project.save()
  36. self.charlies_profile = Profile(user=self.charlie)
  37. self.charlies_profile.current_project = self.charlies_project
  38. self.charlies_profile.save()
  39. self.channels_url = "/projects/%s/integrations/" % self.project.code