Skip to content

Commit 3e4dd66

Browse files
authored
Merge pull request #57 from pythonkr/feature/add-my-schedule-timetable
fix: 세션 북마크 추가 요청 시 필드를 `presentation` -> `presentation_id`로 수정
2 parents d61522f + 000eeb8 commit 3e4dd66

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎app/event/presentation/serializers.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ def fail(self, key, **kwargs):
2121

2222

2323
class PresentationBookmarkRequestSerializer(serializers.Serializer):
24-
presentation = NotFoundPrimaryKeyRelatedField(queryset=Presentation.objects.filter(deleted_at__isnull=True))
24+
presentation_id = NotFoundPrimaryKeyRelatedField(
25+
queryset=Presentation.objects.filter(deleted_at__isnull=True),
26+
source="presentation",
27+
)
2528

2629
def create(self, validated_data: Any) -> tuple[PresentationBookmark, bool]:
2730
validated_data["user"] = self.context["request"].user

‎app/event/presentation/test/bookmark_api_test.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_creates_bookmark_and_returns_201(
219219
"""
220220
response = authed_client.post(
221221
list_url(event.id),
222-
data={"presentation": str(presentation.id)},
222+
data={"presentation_id": str(presentation.id)},
223223
format="json",
224224
)
225225

@@ -235,7 +235,7 @@ def test_sets_event_from_presentation(
235235
북마크 생성 시 presentation의 type.event로부터 event를 자동 설정하는지 검증합니다.
236236
프론트는 POST 시 event를 명시적으로 보내지 않으므로, 서버가 presentation에서 파생해야 합니다.
237237
"""
238-
authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
238+
authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
239239

240240
bookmark = PresentationBookmark.objects.get(user=user, presentation=presentation)
241241
assert bookmark.presentation.type.event.id == event.id
@@ -253,7 +253,7 @@ def test_duplicate_bookmark_returns_200_idempotent(
253253

254254
response = authed_client.post(
255255
list_url(event.id),
256-
data={"presentation": str(presentation.id)},
256+
data={"presentation_id": str(presentation.id)},
257257
format="json",
258258
)
259259

@@ -269,7 +269,7 @@ def test_nonexistent_presentation_returns_404(self, authed_client: APIClient, ev
269269
"""
270270
response = authed_client.post(
271271
list_url(event.id),
272-
data={"presentation": str(uuid.uuid4())},
272+
data={"presentation_id": str(uuid.uuid4())},
273273
format="json",
274274
)
275275

@@ -288,7 +288,7 @@ def test_soft_deleted_presentation_returns_404(
288288

289289
response = authed_client.post(
290290
list_url(event.id),
291-
data={"presentation": str(presentation.id)},
291+
data={"presentation_id": str(presentation.id)},
292292
format="json",
293293
)
294294

@@ -302,7 +302,7 @@ def test_invalid_presentation_id_format_returns_400(self, authed_client: APIClie
302302
"""
303303
response = authed_client.post(
304304
list_url(event.id),
305-
data={"presentation": "not-a-uuid"},
305+
data={"presentation_id": "not-a-uuid"},
306306
format="json",
307307
)
308308

@@ -326,7 +326,7 @@ def test_unauthenticated_returns_403(self, anon_client: APIClient, event: Event,
326326
"""
327327
response = anon_client.post(
328328
list_url(event.id),
329-
data={"presentation": str(presentation.id)},
329+
data={"presentation_id": str(presentation.id)},
330330
format="json",
331331
)
332332

@@ -345,8 +345,8 @@ def test_allows_overlapping_time_sessions(
345345
시간이 겹치는 세션들도 모두 북마크할 수 있는지 검증합니다.
346346
UX 확정 사항: 겹침 경고는 프론트가 처리하고, 서버는 시간대 충돌을 검사하지 않습니다.
347347
"""
348-
resp1 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
349-
resp2 = authed_client.post(list_url(event.id), data={"presentation": str(presentation_2.id)}, format="json")
348+
resp1 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
349+
resp2 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation_2.id)}, format="json")
350350

351351
assert resp1.status_code == http.HTTPStatus.CREATED
352352
assert resp2.status_code == http.HTTPStatus.CREATED
@@ -359,7 +359,7 @@ def test_nonexistent_event_returns_404(self, authed_client: APIClient, presentat
359359
"""
360360
response = authed_client.post(
361361
list_url(uuid.uuid4()),
362-
data={"presentation": str(presentation.id)},
362+
data={"presentation_id": str(presentation.id)},
363363
format="json",
364364
)
365365

@@ -492,7 +492,7 @@ def test_add_remove_re_add_flow(
492492
각 단계에서 GET으로 목록을 조회해 상태가 올바른지 확인합니다.
493493
"""
494494
# 1단계: 담기
495-
resp = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
495+
resp = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
496496
assert resp.status_code == http.HTTPStatus.CREATED
497497

498498
# GET으로 확인: 1개
@@ -508,7 +508,7 @@ def test_add_remove_re_add_flow(
508508
assert len(resp.json()["presentation_ids"]) == 0
509509

510510
# 3단계: 되돌리기 (다시 POST)
511-
resp = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
511+
resp = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
512512
assert resp.status_code == http.HTTPStatus.CREATED
513513

514514
# GET으로 확인: 다시 1개
@@ -540,8 +540,8 @@ def test_rapid_double_post_is_safe(
540540
같은 세션에 대해 POST가 빠르게 2번 연속 호출되어도
541541
두 번째 요청이 에러 없이 200을 반환하고 중복 레코드가 생기지 않는지 검증합니다.
542542
"""
543-
resp1 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
544-
resp2 = authed_client.post(list_url(event.id), data={"presentation": str(presentation.id)}, format="json")
543+
resp1 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
544+
resp2 = authed_client.post(list_url(event.id), data={"presentation_id": str(presentation.id)}, format="json")
545545

546546
assert resp1.status_code == http.HTTPStatus.CREATED
547547
assert resp2.status_code == http.HTTPStatus.OK
@@ -584,7 +584,7 @@ def test_404_follows_error_envelope(self, authed_client: APIClient, event: Event
584584
"""
585585
response = authed_client.post(
586586
list_url(event.id),
587-
data={"presentation": str(uuid.uuid4())},
587+
data={"presentation_id": str(uuid.uuid4())},
588588
format="json",
589589
)
590590

@@ -601,7 +601,7 @@ def test_400_validation_error_follows_envelope(self, authed_client: APIClient, e
601601
"""
602602
response = authed_client.post(
603603
list_url(event.id),
604-
data={"presentation": "invalid"},
604+
data={"presentation_id": "invalid"},
605605
format="json",
606606
)
607607

0 commit comments

Comments
 (0)