conflict resolution
This commit is contained in:
@@ -390,12 +390,11 @@ class ProductSearchTest(TestCase):
|
||||
url = f"{self.endpoint}?query_string={query_string}"
|
||||
# send in request
|
||||
response = self.client.get(url)
|
||||
|
||||
# import ipdb; ipdb.set_trace()
|
||||
# check re sponse
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# check for object creation
|
||||
data = json.loads(response.data)
|
||||
self.assertEquals(len(data), len(expected_instances))
|
||||
self.assertEquals(len(response.data), len(expected_instances))
|
||||
|
||||
|
||||
class MyProductsViewTest(APITestCase):
|
||||
|
||||
@@ -6,7 +6,6 @@ from functools import reduce
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from django.core import serializers
|
||||
from django.db.models import Q
|
||||
|
||||
# Create your views here.
|
||||
@@ -46,8 +45,8 @@ class ProductViewSet(viewsets.ModelViewSet):
|
||||
@permission_classes([IsAuthenticated,])
|
||||
def my_products(request):
|
||||
qs = Product.objects.filter(creator=request.user)
|
||||
data = serializers.serialize('json', qs)
|
||||
return Response(data=data)
|
||||
product_serializer = ProductSerializer(qs)
|
||||
return Response(data=product_serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST',])
|
||||
@@ -166,8 +165,8 @@ def product_search(request):
|
||||
for item in products:
|
||||
result_set.add(item)
|
||||
|
||||
serializer = ProductSerializer(result_set, many=True)
|
||||
|
||||
return Response(data=serializer.data)
|
||||
# serialize and respond
|
||||
product_serializer = ProductSerializer(result_set)
|
||||
return Response(data=product_serializer.data)
|
||||
except Exception as e:
|
||||
return Response({"errors": {"details": str(type(e))}})
|
||||
|
||||
Reference in New Issue
Block a user