more work on serializing tags
This commit is contained in:
@@ -6,7 +6,7 @@ from products.models import Product
|
||||
from utils.tag_serializers import SingleTagSerializerField, CustomTagSerializer
|
||||
|
||||
|
||||
class ProductSerializer(CustomTagSerializer):
|
||||
class ProductSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
|
||||
tags = TagListSerializerField(required=False)
|
||||
category = SingleTagSerializerField(required=False) # main tag category
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.utils import timezone
|
||||
from rest_framework.test import APITestCase
|
||||
from rest_framework import status
|
||||
|
||||
from companies.factories import CompanyFactory
|
||||
from products.factories import ProductFactory
|
||||
from products.models import Product
|
||||
|
||||
@@ -101,12 +102,12 @@ class ProductViewSetTest(APITestCase):
|
||||
"""Regular logged-in user can create new instance
|
||||
"""
|
||||
# Define request data
|
||||
company = CompanyFactory()
|
||||
data = {
|
||||
'company': None,
|
||||
'company': company.id,
|
||||
'sku': 'qwerewq',
|
||||
'name': 'qwerewq',
|
||||
'description': 'qwerewq',
|
||||
'image': None,
|
||||
'url': 'http://qwerewq.com',
|
||||
'price': '12.21',
|
||||
'shipping_cost': '21.12',
|
||||
@@ -128,7 +129,6 @@ class ProductViewSetTest(APITestCase):
|
||||
|
||||
# Query endpoint
|
||||
response = self.client.post(self.endpoint, data=data, format='json')
|
||||
|
||||
# Assert endpoint returns created status
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
|
||||
@@ -145,8 +145,9 @@ class ProductViewSetTest(APITestCase):
|
||||
instance.save()
|
||||
|
||||
# Define request data
|
||||
company = CompanyFactory()
|
||||
data = {
|
||||
'company': None,
|
||||
'company': company.id,
|
||||
'sku': 'qwerewq',
|
||||
'name': 'qwerewq',
|
||||
'description': 'qwerewq',
|
||||
@@ -173,7 +174,7 @@ 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user