Пример #1
0
    def test_after_order_taken_status(self):
        """
        Ensure Invalid Method response
        """
        self.create_customer_volunteer_data()
        self.add_customer_entry()
        access_token = common_test_functionality.get_customer_access(
            email=self.volunteer_email, password=self.password)
        # self.url = reverse('customer:customer-details', kwargs={'uid': entry_created.uid})
        self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
        entry_created = CustomerDetails.objects.all()[0]
        update_customer_detail_url = reverse('customer:customer-details',
                                             kwargs={'uid': entry_created.uid})
        data = self.get_customer_entry()
        response = self.client.patch(update_customer_detail_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)

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            response.data['custom_code'], common_success_response.
            success_customer_location_volunteering.custom_code)
Пример #2
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)
Пример #3
0
 def add_customer_entry(self):
     access_token = common_test_functionality.get_customer_access(
         email=self.customer_email, password=self.password)
     data = self.get_customer_entry()
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.post(self.customer_entry_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_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)
Пример #5
0
 def test_no_order_taken_method(self):
     """
     Ensure Invalid Method response
     """
     self.create_customer_volunteer_data()
     self.add_customer_entry()
     access_token = common_test_functionality.get_customer_access(
         email=self.volunteer_email, password=self.password)
     # self.url = reverse('customer:customer-details', kwargs={'uid': entry_created.uid})
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
     self.assertEqual(
         response.data['custom_code'],
         common_failure_response.no_customer_order_taken.custom_code)
Пример #6
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)
Пример #7
0
 def test_invalid_method(self):
     """
     Ensure Invalid Method response
     """
     self.create_customer_volunteer_data()
     self.add_customer_entry()
     access_token = common_test_functionality.get_customer_access(
         email=self.volunteer_email, password=self.password)
     # self.url = reverse('customer:customer-details', kwargs={'uid': entry_created.uid})
     self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + access_token)
     response = self.client.delete(self.url)
     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)
Пример #8
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)