From 000eeb8256be35a834b5212f3dc47343a8975412 Mon Sep 17 00:00:00 2001 From: earthyoung Date: Fri, 17 Jul 2026 16:59:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20POST=20=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=EB=A5=BC=20presentation=20->=20presentation?= =?UTF-8?q?=5Fid=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/event/presentation/serializers.py | 5 ++- .../presentation/test/bookmark_api_test.py | 32 +++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/event/presentation/serializers.py b/app/event/presentation/serializers.py index 97f1c0c..c3aa291 100644 --- a/app/event/presentation/serializers.py +++ b/app/event/presentation/serializers.py @@ -21,7 +21,10 @@ def fail(self, key, **kwargs): class PresentationBookmarkRequestSerializer(serializers.Serializer): - presentation = NotFoundPrimaryKeyRelatedField(queryset=Presentation.objects.filter(deleted_at__isnull=True)) + presentation_id = NotFoundPrimaryKeyRelatedField( + queryset=Presentation.objects.filter(deleted_at__isnull=True), + source="presentation", + ) def create(self, validated_data: Any) -> tuple[PresentationBookmark, bool]: validated_data["user"] = self.context["request"].user diff --git a/app/event/presentation/test/bookmark_api_test.py b/app/event/presentation/test/bookmark_api_test.py index fda8a48..6ef3f11 100644 --- a/app/event/presentation/test/bookmark_api_test.py +++ b/app/event/presentation/test/bookmark_api_test.py @@ -219,7 +219,7 @@ def test_creates_bookmark_and_returns_201( """ response = authed_client.post( list_url(event.id), - data={"presentation": str(presentation.id)}, + data={"presentation_id": str(presentation.id)}, format="json", ) @@ -235,7 +235,7 @@ def test_sets_event_from_presentation( 북마크 생성 시 presentation의 type.event로부터 event를 자동 설정하는지 검증합니다. 프론트는 POST 시 event를 명시적으로 보내지 않으므로, 서버가 presentation에서 파생해야 합니다. """ - authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") + authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") bookmark = PresentationBookmark.objects.get(user=user, presentation=presentation) assert bookmark.presentation.type.event.id == event.id @@ -253,7 +253,7 @@ def test_duplicate_bookmark_returns_200_idempotent( response = authed_client.post( list_url(event.id), - data={"presentation": str(presentation.id)}, + data={"presentation_id": str(presentation.id)}, format="json", ) @@ -269,7 +269,7 @@ def test_nonexistent_presentation_returns_404(self, authed_client: APIClient, ev """ response = authed_client.post( list_url(event.id), - data={"presentation": str(uuid.uuid4())}, + data={"presentation_id": str(uuid.uuid4())}, format="json", ) @@ -288,7 +288,7 @@ def test_soft_deleted_presentation_returns_404( response = authed_client.post( list_url(event.id), - data={"presentation": str(presentation.id)}, + data={"presentation_id": str(presentation.id)}, format="json", ) @@ -302,7 +302,7 @@ def test_invalid_presentation_id_format_returns_400(self, authed_client: APIClie """ response = authed_client.post( list_url(event.id), - data={"presentation": "not-a-uuid"}, + data={"presentation_id": "not-a-uuid"}, format="json", ) @@ -326,7 +326,7 @@ def test_unauthenticated_returns_403(self, anon_client: APIClient, event: Event, """ response = anon_client.post( list_url(event.id), - data={"presentation": str(presentation.id)}, + data={"presentation_id": str(presentation.id)}, format="json", ) @@ -345,8 +345,8 @@ def test_allows_overlapping_time_sessions( 시간이 겹치는 세션들도 모두 북마크할 수 있는지 검증합니다. UX 확정 사항: 겹침 경고는 프론트가 처리하고, 서버는 시간대 충돌을 검사하지 않습니다. """ - resp1 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") - resp2 = authed_client.post(list_url(event.id), data={"presentation": str(presentation_2.id)}, format="json") + resp1 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") + resp2 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation_2.id)}, format="json") assert resp1.status_code == http.HTTPStatus.CREATED assert resp2.status_code == http.HTTPStatus.CREATED @@ -359,7 +359,7 @@ def test_nonexistent_event_returns_404(self, authed_client: APIClient, presentat """ response = authed_client.post( list_url(uuid.uuid4()), - data={"presentation": str(presentation.id)}, + data={"presentation_id": str(presentation.id)}, format="json", ) @@ -492,7 +492,7 @@ def test_add_remove_re_add_flow( 각 단계에서 GET으로 목록을 조회해 상태가 올바른지 확인합니다. """ # 1단계: 담기 - resp = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") + resp = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") assert resp.status_code == http.HTTPStatus.CREATED # GET으로 확인: 1개 @@ -508,7 +508,7 @@ def test_add_remove_re_add_flow( assert len(resp.json()["presentation_ids"]) == 0 # 3단계: 되돌리기 (다시 POST) - resp = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") + resp = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") assert resp.status_code == http.HTTPStatus.CREATED # GET으로 확인: 다시 1개 @@ -540,8 +540,8 @@ def test_rapid_double_post_is_safe( 같은 세션에 대해 POST가 빠르게 2번 연속 호출되어도 두 번째 요청이 에러 없이 200을 반환하고 중복 레코드가 생기지 않는지 검증합니다. """ - resp1 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") - resp2 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json") + resp1 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") + resp2 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json") assert resp1.status_code == http.HTTPStatus.CREATED assert resp2.status_code == http.HTTPStatus.OK @@ -584,7 +584,7 @@ def test_404_follows_error_envelope(self, authed_client: APIClient, event: Event """ response = authed_client.post( list_url(event.id), - data={"presentation": str(uuid.uuid4())}, + data={"presentation_id": str(uuid.uuid4())}, format="json", ) @@ -601,7 +601,7 @@ def test_400_validation_error_follows_envelope(self, authed_client: APIClient, e """ response = authed_client.post( list_url(event.id), - data={"presentation": "invalid"}, + data={"presentation_id": "invalid"}, format="json", )