Пример #1
0
 def test_invalid_method(self):
     """
     Ensure Invalid Method response
     """
     entry_created = common_test_functionality.create_customer_grocery_entry_data(
     )
     created_user = common_test_functionality.create_data(
         password=self.password, is_customer=True)
     access_token = common_test_functionality.get_customer_access(
         email=created_user.email, password=self.password)
     self.url = reverse('customer:customer-details',
                        kwargs={'uid': entry_created.uid})
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     data = self.get_data()
     response = self.client.post(self.url, data, format='json')
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
     self.assertEqual(
         response.data['custom_code'],
         common_failure_response.method_not_allowed.custom_code)
     response = self.client.delete(self.url, data, format='json')
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
     self.assertEqual(
         response.data['custom_code'],
         common_failure_response.method_not_allowed.custom_code)
Пример #2
0
 def test_invaild_data(self):
     """
     Ensure response Type for serializer error field
     """
     created_user = common_test_functionality.create_data(
         is_customer=True, password=self.password)
     access_token = common_test_functionality.get_customer_access(
         email=created_user.email, password=self.password)
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.post(self.url, {}, format='json')
     self.assertEqual(response.status_code,
                      status.HTTP_422_UNPROCESSABLE_ENTITY)
     self.assertEqual(response.data['custom_code'],
                      common_failure_response.validation_error.custom_code)
Пример #3
0
 def test_vaild_data(self):
     """
     Ensure we can create a new customer object.
     """
     created_user = common_test_functionality.create_data(
         password=self.password, is_customer=True)
     access_token = common_test_functionality.get_customer_access(
         email=created_user.email, password=self.password)
     data = self.get_data()
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.post(self.url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(
         response.data['custom_code'],
         common_success_response.success_customer_data_entry.custom_code)
Пример #4
0
 def test_valid_patch_data(self):
     """
     Ensure we can update a single value of customer object.
     """
     entry_created = common_test_functionality.create_customer_grocery_entry_data(
     )
     created_user = common_test_functionality.create_data(
         password=self.password, is_customer=True)
     access_token = common_test_functionality.get_customer_access(
         email=created_user.email, password=self.password)
     self.url = reverse('customer:customer-details',
                        kwargs={'uid': entry_created.uid})
     data = self.get_data()
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.put(self.url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(
         response.data['custom_code'],
         common_success_response.success_customer_update.custom_code)
Пример #5
0
 def test_invalid_data_entry(self):
     volunteer = common_test_functionality.create_data(is_volunteer=False)
     self.assertTrue(isinstance(volunteer, Volunteer))
     volunteer_entry = VolunteerProfileData.objects.filter(volunteer=volunteer)
     self.assertEqual(len(volunteer_entry), 0)
Пример #6
0
 def test_data_entry(self):
     customer = common_test_functionality.create_data(is_customer=True)
     self.assertTrue(isinstance(customer, Volunteer))
     customer_entry = CustomerProfileData.objects.filter(volunteer=customer)
     self.assertEqual(len(customer_entry), 1)
Пример #7
0
 def test_data_entry(self):
     volunteer = common_test_functionality.create_data()
     self.assertTrue(isinstance(volunteer, Volunteer))