Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/event/presentation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions app/event/presentation/test/bookmark_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand All @@ -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
Expand All @@ -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",
)

Expand All @@ -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",
)

Expand All @@ -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",
)

Expand All @@ -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",
)

Expand All @@ -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",
)

Expand All @@ -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
Expand All @@ -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",
)

Expand Down Expand Up @@ -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개
Expand All @@ -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개
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
)

Expand All @@ -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",
)

Expand Down
Loading