Ejemplo n.º 1
0
 def test_user_create_contact(self):
     user_auth = authentication(self)
     self.client.credentials(HTTP_AUTHORIZATION=user_auth[0])
     temp_user = user_auth[1]
     url = reverse('contact-add', kwargs={'pk': temp_user.id})
     response = self.client.post(url, self.valid_data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 2
0
 def test_non_admin_and_pm_add_member(self):
     url = reverse('team-add-member', kwargs={'pk': self.team.id})
     temp_authentication = authentication(self, staff=False)
     self.client.credentials(HTTP_AUTHORIZATION=temp_authentication[0])
     data = {'emails': f'{self.member.email}'}
     response = self.client.put(url, data)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 3
0
 def test_non_admin_set_line_manager(self):
     url = reverse('profile-set-line-manager',
                   kwargs={'pk': self.user_profile.id})
     data = {'name': f'{self.manager_profile.name}'}
     self.client.credentials(HTTP_AUTHORIZATION=authentication(self)[0])
     response = self.client.post(url, data)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 4
0
 def test_non_admin_add_pm(self):
     url = reverse('team-set-project-manager', kwargs={'pk': self.team.id})
     nadmin_authentication = authentication(self, staff=False)
     self.client.credentials(HTTP_AUTHORIZATION=nadmin_authentication[0])
     data = {'email': f'{self.pm.email}'}
     response = self.client.put(url, data)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 5
0
 def setUp(self):
     self.User = UserFactory._meta.model
     self.Profile = ProfileFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user = self.authentication[1]
     self.user_profile = self.Profile.objects.get(user=self.user)
     self.manager = UserFactory.create()
     self.manager_profile = ProfileFactory.create(user=self.manager)
Ejemplo n.º 6
0
 def test_pm_add_member(self):
     url = reverse('team-add-member', kwargs={'pk': self.team.id})
     pm_authentication = authentication(self, staff=False)
     self.client.credentials(HTTP_AUTHORIZATION=pm_authentication[0])
     pm_authentication[1].title = Titles.TITLES[2][0]
     pm_authentication[1].save()
     self.team.project_manager = pm_authentication[1]
     self.team.save()
     data = {'emails': f'{self.member.email}'}
     response = self.client.put(url, data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 7
0
 def setUp(self):
     self.UserFamilyMembers = UserFamilyMembersFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user_family = UserFamilyMembersFactory.create(user=self.user)
     self.valid_data = {
         "name": "abcxyz",
         "date_of_birth": "2020-01-01",
         "relationship": "CHILD",
     }
     self.invalid_data = {"name": ""}
Ejemplo n.º 8
0
 def setUp(self):
     self.Team = Team._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.pm = UserFactory.create()
     self.pm_profile = ProfileFactory(user=self.pm)
     self.member = UserFactory.create()
     self.memberProfile = ProfileFactory(user=self.member)
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.team = TeamFactory.create(team_name=factory.Faker('name'),
                                    team_email=factory.Faker('email'),
                                    team_leader=self.user)
Ejemplo n.º 9
0
 def setUp(self):
     self.UserInsurance = UserInsuranceFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user_insurance = UserInsuranceFactory.create(user=self.user)
     self.valid_data = {
         "social_insurance_code": "abcxyz123",
         "start_date": "2020-01-01"
     }
     self.invalid_data = {
         "social_insurance_code": "",
     }
Ejemplo n.º 10
0
 def setUp(self):
     self.UserIdentity = UserIdentityFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user_identity = UserIdentityFactory.create(user=self.user)
     self.valid_data = {
         "identity_number": "1231231231",
         "issue_date": "2020-01-01",
         "issue_place": "DN",
         "place_of_birth": "DN"
     }
     self.invalid_data = {
         "identity_number": "",
     }
Ejemplo n.º 11
0
 def setUp(self):
     self.UserEducation = UserEducationFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user_education = UserEducationFactory.create(user=self.user)
     self.valid_data = {
         "school": "bkdn",
         "degree": "master",
         "field_of_study": "it",
         "graduated_year": "2000",
     }
     self.invalid_data = {
         "school": ""
     }
Ejemplo n.º 12
0
 def setUp(self):
     self.UserBanks = UserBanksFactory._meta.model
     self.Banks = BanksFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.bank = BanksFactory.create()
     self.user_bank = UserBanksFactory.create(user=self.user,
                                              bank=self.bank)
     self.valid_data = {
         "account_number": "123123123123",
         "bank": f"{self.bank.id}",
         "branch": "Da Nang"
     }
     self.invalid_data = {
         "account_number": "",  # not allow null
     }
Ejemplo n.º 13
0
 def setUp(self):
     self.UserContact = UserContactFactory._meta.model
     self.authentication = authentication(self, staff=True)
     self.user = self.authentication[1]
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
     self.user_contact = UserContactFactory.create(
         user=self.authentication[1])
     self.valid_data = {
         "permanent_address": "1 abc",
         "temporary_address": "2 def",
         "household_registration_number": "123456",
         "contact_emergency": "1234567890",
     }
     self.invalid_data = {
         "permanent_address": "",  # not allow null
         "temporary_address": "",
         "household_registration_number": "",
         "contact_emergency": "",
     }
Ejemplo n.º 14
0
 def setUp(self):
     self.User = UserFactory._meta.model
     self.Profile = ProfileFactory._meta.model
     self.list_user = []
     for i in range(NUMBER_OF_SAMPLE):
         temp_user = UserFactory(
             title=title_list[randint(0,
                                      len(title_list) - 1)])
         _ = ProfileFactory(
             user=temp_user,
             name=name_list[randint(0,
                                    len(name_list) - 1)],
             birth_day=birthday_list[randint(0,
                                             len(birthday_list) - 1)],
             gender=gender_list[randint(0,
                                        len(gender_list) - 1)],
             join_date=joindate_list[randint(0,
                                             len(joindate_list) - 1)],
         )
         self.list_user.append(temp_user)
     self.authentication = authentication(self, staff=True)
     self.client.credentials(HTTP_AUTHORIZATION=self.authentication[0])
Ejemplo n.º 15
0
 def test_non_admin_remove_line_manager(self):
     url = reverse('profile-remove-line-manager',
                   kwargs={'pk': self.user_profile.id})
     self.client.credentials(HTTP_AUTHORIZATION=authentication(self)[0])
     response = self.client.delete(url)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 16
0
 def test_user_delete_contact(self):
     url = reverse('contact-detail', kwargs={'pk': self.user.id})
     self.client.credentials(HTTP_AUTHORIZATION=authentication(self)[0])
     response = self.client.delete(url)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 17
0
 def test_user_update_not_owner_education(self):
     url = reverse('education-detail', kwargs={'pk': self.user.id})
     self.valid_data['id'] = self.user_education.id
     self.client.credentials(HTTP_AUTHORIZATION=authentication(self)[0])
     response = self.client.put(url, self.valid_data)
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)