def make_validated_serializer(**kwargs): data = create_product_data() data = dict(data, **kwargs) serializer = ProductSerializer(data=data) serializer.is_valid() return serializer
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.']})
def setUp(self): self.url = reverse('product-list') self.data = create_product_data() self.response = self.client.post(self.url, self.data)
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.']})
def setUp(self): self.obj = Product.objects.create(**create_product_data())