Example #1
0
 def test_put_update_cart_item_quantity_bad_request(self):
     # Try to update a not existing item
     data = {'quantity': 5}
     wrong_product_id = factories.Faker('uuid4').generate()
     resp = self.put_json(data=data, fragment=f'{wrong_product_id}/')
     self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
     self.has_attribute_errors(resp)
Example #2
0
 def test_put_pay_not_existed_order_bad_request(self):
     """
     API PUT /api/v1/orders/me/{order_id}/payment/
     """
     order_id = factories.Faker('uuid4').generate()
     resp = self.put_json(data={}, fragment=f'{order_id}/payment/')
     self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
     self.has_valid_custom_error_response(resp)
Example #3
0
class AddressBookFactory(factories.ModelFactory):
    """
    Factory customer address
    """
    address = factories.Faker('address')

    class Meta:
        model = AddressBook
        django_get_or_create = ('customer', )
Example #4
0
class EmailFactory(factories.ModelFactory):
    # Factory data for Membership model.

    email = factories.Faker('email')
    is_verified = factories.FuzzyChoice([True, False])

    class Meta:
        model = Email
        django_get_or_create = (
            'email',
            'is_verified',
        )
Example #5
0
    def test_user_can_be_updated(self):
        update_data = {
            'email': factories.Faker('email').generate(),
        }
        for key, value in update_data.items():
            setattr(self.user, key, value)

        self.user.save()
        self.assertEqual(self.user.email, update_data['email'])

        # Check customer of this user
        customer_obj = Customer.objects.filter(account=self.user)[0]
        self.assertEqual(customer_obj.email.email, update_data['email'])
Example #6
0
 def test_delete_cart_item_bad_request(self):
     _, cart_item_objs = self.generate_cart_and_its_items()
     wrong_product_id = factories.Faker('uuid4').generate()
     resp = self.delete_json(data={}, fragment=f'{wrong_product_id}/')
     self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
     self.has_valid_custom_error_response(resp)
Example #7
0
 def test_put_add_shipping_address_to_cart_not_found(self):
     wrong_address_id = factories.Faker('uuid4').generate()
     resp = self.put_json(data={}, fragment=f'{wrong_address_id}/')
     print(resp.__dict__)
     self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
     self.has_attribute_errors(resp)