예제 #1
0
    def setUp(self):
        self.bob_user = User.objects.create_user(username='******',
                                                 password='******',
                                                 email='*****@*****.**',
                                                 first_name = 'bob',
                                                 last_name = 'dylan')
        self.bob_employee = Employee(user=self.bob_user, holidays_per_year=21)
        self.bob_employee.save()

        self.alice_user = User.objects.create_user(username='******',
                                                   password='******',
                                                   email='*****@*****.**',
                                                   first_name = 'alice',
                                                   last_name = 'wonderland')
        self.alice_employee = Employee(user=self.alice_user, holidays_per_year=21)
        self.alice_employee.save()

        self.boss_user = User.objects.create_user(username='******',
                                                  password='******',
                                                  email='*****@*****.**',
                                                  first_name = 'boss',
                                                  last_name = 'boss')
        self.boss_employee = Employee(user=self.boss_user, holidays_per_year=21)
        self.boss_employee.save()

        self.another_boss_user = User.objects.create_user(username='******',
                                                          password='******',
                                                          email='*****@*****.**',
                                                          first_name = 'another_boss',
                                                          last_name = 'another_boss')
        self.another_boss_employee = Employee(user=self.another_boss_user, holidays_per_year=21)
        self.another_boss_employee.save()

        self.ceo_user = User.objects.create_user(username='******',
                                                 password='******',
                                                 email='*****@*****.**',
                                                 first_name = 'ceo',
                                                 last_name = 'spyhce')
        self.ceo_employee = Employee(user=self.ceo_user, holidays_per_year=21)
        self.ceo_employee.save()

        self.project_alpha = Project(project_name = 'project_alpha')
        self.project_alpha.save()
        self.project_alpha.team_leaders.add(self.boss_employee, self.ceo_employee)
        self.project_alpha.employees.add(self.boss_employee, self.bob_employee)
        self.project_alpha.save()

        self.project_beta = Project(project_name = 'project_beta')
        self.project_beta.save()
        self.project_beta.team_leaders.add(self.another_boss_employee, self.ceo_employee)
        self.project_beta.employees.add(self.another_boss_employee, self.alice_employee)
        self.project_beta.save()

        self.factory = RequestFactory()
예제 #2
0
class SettingUpDB(TestCase):
    """
    Only used to setup the DB.
    Bob and Alice are employees of Spyhce.
    Bob is working on project alpha whose the team leader are boss and ceo.
    Alice is working on project beta whose the team leader are another_boss and ceo.
    """
    def setUp(self):
        self.bob_user = User.objects.create_user(username='******',
                                                 password='******',
                                                 email='*****@*****.**',
                                                 first_name = 'bob',
                                                 last_name = 'dylan')
        self.bob_employee = Employee(user=self.bob_user, holidays_per_year=21)
        self.bob_employee.save()

        self.alice_user = User.objects.create_user(username='******',
                                                   password='******',
                                                   email='*****@*****.**',
                                                   first_name = 'alice',
                                                   last_name = 'wonderland')
        self.alice_employee = Employee(user=self.alice_user, holidays_per_year=21)
        self.alice_employee.save()

        self.boss_user = User.objects.create_user(username='******',
                                                  password='******',
                                                  email='*****@*****.**',
                                                  first_name = 'boss',
                                                  last_name = 'boss')
        self.boss_employee = Employee(user=self.boss_user, holidays_per_year=21)
        self.boss_employee.save()

        self.another_boss_user = User.objects.create_user(username='******',
                                                          password='******',
                                                          email='*****@*****.**',
                                                          first_name = 'another_boss',
                                                          last_name = 'another_boss')
        self.another_boss_employee = Employee(user=self.another_boss_user, holidays_per_year=21)
        self.another_boss_employee.save()

        self.ceo_user = User.objects.create_user(username='******',
                                                 password='******',
                                                 email='*****@*****.**',
                                                 first_name = 'ceo',
                                                 last_name = 'spyhce')
        self.ceo_employee = Employee(user=self.ceo_user, holidays_per_year=21)
        self.ceo_employee.save()

        self.project_alpha = Project(project_name = 'project_alpha')
        self.project_alpha.save()
        self.project_alpha.team_leaders.add(self.boss_employee, self.ceo_employee)
        self.project_alpha.employees.add(self.boss_employee, self.bob_employee)
        self.project_alpha.save()

        self.project_beta = Project(project_name = 'project_beta')
        self.project_beta.save()
        self.project_beta.team_leaders.add(self.another_boss_employee, self.ceo_employee)
        self.project_beta.employees.add(self.another_boss_employee, self.alice_employee)
        self.project_beta.save()

        self.factory = RequestFactory()