Пример #1
0
def make_validated_serializer(**kwargs):
    data = create_product_data()
    data = dict(data, **kwargs)
    serializer = ProductSerializer(data=data)
    serializer.is_valid()

    return serializer
Пример #2
0
 def test_incorrect_minimum_stock(self):
     data = create_product_data(minimum_stock='xa')
     response = self.client.post(self.url, data)
     self.assertEqual(json.loads(response.content), {
                      'minimum_stock': ['A valid integer is required.']})
Пример #3
0
 def setUp(self):
     self.url = reverse('product-list')
     self.data = create_product_data()
     self.response = self.client.post(self.url, self.data)
Пример #4
0
 def test_create_product_invalid_post_string_price(self):
     data = create_product_data(price='sds')
     response = self.client.post(self.url, data)
     self.assertEqual(json.loads(response.content), {
                      'price': ['A valid number is required.']})
Пример #5
0
 def setUp(self):
     self.obj = Product.objects.create(**create_product_data())