refactoring2 [Django] DRF - 1차 프로젝트 리팩토링 (4) API Testing 2 1. Cart 이번에는 cart api 테스트 코드를 작성했다. cart의 경우 get, post, put, delete의 모든 기능이 있었기 때문에 모든 부분을 진행했고, cart-detail에 관련된 부분은 reverse 내부에서 args를 설정했다. from django.urls import reverse from django.contrib.auth.models import User from rest_framework.test import APITestCase from rest_framework_simplejwt.tokens import RefreshToken from carts.models import Cart from products.models import * class CartTest(API.. 2022. 6. 15. [Django] DRF - 1차 프로젝트 리팩토링 (4) API Testing API 부분의 리팩토링이 어느 정도 끝난 후 test code를 작성했다. 1. Category & Product 먼저 category와 product의 detail과 list를 get에 관련한 테스트 코드를 작성했다. # category class CategoryTestCase(APITestCase): def setUp(self): self.category = Category.objects.create( category_name = 'test category', main_description = 'test main description', sub_description = 'test sub description' ) def test_category_list_get(self): response = self.. 2022. 6. 14. 이전 1 다음