[백엔드]
1. 어제 한 일
-. RDS 서버 DB 통일 및 복구 완료
-. 1071 에러 해결 및 유닛테스트(소셜 로그인 / 메인페이지) ; 풀리퀘스트 대기중
-. 크리에이터 지원 views.py 역할 분담 후 시작
2. 블로킹 :
[프론트엔드]
1. PR 올라간 것들 수정 및 맞춰보기(merging 필요)
2. 로그인 로그아웃 내부바 400 오류 해결 / 카카오 로그아웃 지속 시도 중(블로킹요소 발견) + 크리에이터 지원 레이아웃
3. 메인페이지 패치 쿼리 맞춰보기(익일까지 예상)
4. 모달 머지 + 상품 관련 연속된 것 수정 사항 + 크리에이터 지원만 마무리 되면 끝
[4:30~5:30 LOVE 면담]
creator / views.py
데코레이터 안 되어서 하드코딩 진행하다보니 테스트에서 자꾸 에러 남
import json, bcrypt, jwt, boto3, os, logging, uuid
from json import JSONDecodeError
from django.views import View
from django.http import JsonResponse
from django.db import transaction, IntegrityError
from django.core.exceptions import ObjectDoesNotExist
from my_settings import AWS_STORAGE_BUCKET_NAME
from creator.custom_storage import MediaStorage
from lecture.models import (
Category, SubCategory, Difficulty,
Hashtag, PendingLecture, PendingLectureHashtag,
Introduction, Vote)
from user.models import User, Creator
from utils.decorators import auth_check
class BasicInformationView(View):
# @auth_check
def post(self,request):
try:
data = json.loads(request.body)
user_id = User.objects.get(id=7).id
sub_category_id = data.get('sub_category_id')
detailed_category = data.get('detailed_category')
difficulty_id = data.get('difficulty_id')
with transaction.atomic():
if not PendingLecture.objects.filter(user_id=user_id).exists():
basic_information = PendingLecture.objects.create(
sub_category_id = sub_category_id,
detailed_category = detailed_category,
difficulty_id = difficulty_id,
user = user
)
else:
basic_information = PendingLecture.objects.update(
sub_category_id = sub_category_id,
detailed_category = detailed_category,
difficulty_id = difficulty_id,
user = user
)
return JsonResponse({'message' : 'SUCCESS'}, status=201)
except KeyError:
return JsonResponse({'message': 'KEY_ERROR'}, status=400)
except JSONDecodeError:
return JsonResponse({'message': 'JSON_DECODE_ERROR'}, status=400)
except IntegrityError:
return JsonResponse({'message': 'INTEGRITY_ERROR'}, status=400)
except TypeError:
return JsonResponse({'message': 'TYPE_ERROR'}, status=400)
except ObjectDoesNotExist:
return JsonResponse({'message' : 'USER_DOES_NOT_EXIST'}, status=400)
test.py
import json
from django.test import TransactionTestCase, Client
from unittest.mock import patch, MagicMock
from user.models import User, Creator
from creator.views import BasicInformationView
from lecture.models import (
Category, SubCategory, Difficulty,
Hashtag, PendingLecture, PendingLectureHashtag,
Introduction, Vote)
TEST_DATA = {
"data" : {
"sub_category_id" : "2",
"detailed_category" : "손뜨개 코바늘",
"difficulty" : "3"
}
}
class BasicInformationViewTest(TransactionTestCase):
def setUp(self):
User.objects.create(
username = "안다민",
email = 'damin0320@gmail.com',
kakao_id = '1234567890'
)
PendingLecture.objects.create(
title = "신나는 가죽공예",
cover_image_url = "https://class2oo0k.s3.ap-northeast-2.amazonaws.com/media/misa.jpeg",
summary_image_url = "https://class2oo0k.s3.ap-northeast-2.amazonaws.com/media/misa_note.jpeg",
)
def tearDown(self):
User.objects.all().delete()
PendingLecture.objects.all().delete()
def test_basic_information_post_success(self):
client = Client()
response = client.post('/creator/basic-information', json.dumps(TEST_DATA), content_type='application/json').json()
self.assertEqual(response.get('message'), 'SUCCESS')