everythin working except for creation product insance with category

This commit is contained in:
Sam
2021-01-26 11:20:48 +00:00
parent 0e5aee73c3
commit 4437037710
4 changed files with 99 additions and 92 deletions

View File

@@ -17,7 +17,7 @@ class ProductFactory(DjangoModelFactory):
name = FuzzyText(prefix='NAME_', length=10)
description = FuzzyText(prefix='DECRIPTION', length=100)
image = None
url = FuzzyText(prefix='http://WEB_LINK_', suffix='.test', length=10)
url = FuzzyText(prefix='http://WEB-LINK-', suffix='.test', length=10)
price = FuzzyDecimal(low=1.00)
shipping_cost = FuzzyDecimal(low=1.00)
shipping_terms = FuzzyText(prefix='SHIPPING_TERMS', length=100)

View File

@@ -3,7 +3,7 @@ from rest_framework import serializers
from taggit_serializer.serializers import TagListSerializerField, TaggitSerializer
from products.models import Product
from utils.tag_serializers import SingleTagSerializerField, CustomTagSerializer
from utils.tag_serializers import TagListSerializerField, TaggitSerializer, SingleTagSerializerField
class ProductSerializer(TaggitSerializer, serializers.ModelSerializer):
@@ -14,4 +14,5 @@ class ProductSerializer(TaggitSerializer, serializers.ModelSerializer):
class Meta:
model = Product
exclude = ['created', 'updated', 'creator']
# exclude = ['created', 'updated', 'creator']
fields = '__all__'

View File

@@ -118,7 +118,7 @@ class ProductViewSetTest(APITestCase):
'discount': '0.05',
'stock': 22,
'tags': ['tag1, tag2'],
# 'category': 'MayorTagCategory',
# 'category': '',
'attributes': ['color/red', 'size/xxl'],
'identifiers': '34rf34f43c43',
}
@@ -129,6 +129,7 @@ class ProductViewSetTest(APITestCase):
# Query endpoint
response = self.client.post(self.endpoint, data=data, format='json')
import ipdb; ipdb.set_trace()
# Assert endpoint returns created status
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
@@ -162,7 +163,7 @@ class ProductViewSetTest(APITestCase):
'discount': '0.05',
'stock': 22,
'tags': ['tag1x, tag2x'],
# 'category': 'MayorTagCategory2',
'category': 'MayorTagCategory2',
'attributes': ['color/blue', 'size/m'],
'identifiers': '34rf34f43c43',
}
@@ -174,7 +175,6 @@ class ProductViewSetTest(APITestCase):
# Query endpoint
url = self.endpoint + f'{instance.pk}/'
response = self.client.put(url, data, format='json')
import ipdb; ipdb.set_trace()
# Assert endpoint returns OK code
self.assertEqual(response.status_code, status.HTTP_200_OK)