Coverage for tests\movie\test_movie_info.py: 100%
217 statements
« prev ^ index » next coverage.py v7.10.1, created at 2025-10-19 21:13 +0800
« prev ^ index » next coverage.py v7.10.1, created at 2025-10-19 21:13 +0800
1from random import choice
2from tests.conftest import get_json_val, get_reviews_last_page, MOVIE_ENG
3import json
4import pytest
7@pytest.mark.parametrize("path", [
8 "abc"
9 "14348",
10])
11def test_info_input_not_valid_integer(client_nc, path) -> None:
12 resp = client_nc.get(f"/movies/{path}")
13 resp_data = resp.json()
15 assert resp.status_code == 422
16 for err in get_json_val(resp_data, "$.detail"):
17 assert get_json_val(err, "$.msg") == "Input should be a valid integer, unable to parse string as an integer"
20@pytest.mark.parametrize("path", [
21 ("abc", ""),
22 ("14348", ""),
23 ("14348", "?page"),
24 ("14348", "?page="),
25 ("14348", "?page=def"),
26 ("14348", "?page=2"),
27])
28def test_review_input_not_valid_integer(client_nc, path) -> None:
29 resp = client_nc.get(f"/movies/{path[0]}/reviews{path[1]}")
30 resp_data = resp.json()
32 assert resp.status_code == 422
33 for err in get_json_val(resp_data, "$.detail"):
34 assert get_json_val(err, "$.msg") == "Input should be a valid integer, unable to parse string as an integer"
37@pytest.mark.parametrize("path", [
38 ("14348", "?page=0"),
39])
40def test_review_input_less_than_min_threshold(client_nc, path) -> None:
41 resp = client_nc.get(f"/movies/{path[0]}/reviews{path[1]}")
42 resp_data = resp.json()
44 assert resp.status_code == 422
45 for err in get_json_val(resp_data, "$.detail"):
46 assert get_json_val(err, "$.msg") == "Input should be greater than 0"
49@pytest.mark.parametrize("path", [
50 ("14348", "?page=10001"),
51])
52def test_review_input_more_than_max_threshold(client_nc, path) -> None:
53 resp = client_nc.get(f"/movies/{path[0]}/reviews{path[1]}")
54 resp_data = resp.json()
56 assert resp.status_code == 422
57 for err in get_json_val(resp_data, "$.detail"):
58 assert get_json_val(err, "$.msg") == "Input should be less than or equal to 10000"
60@pytest.mark.parametrize(
61 "test_data",
62 [
63 {
64 "title": "ダークナイト",
65 "original_title": "The Dark Knight",
66 "rating": 4.2,
67 "mark_count": 206293,
68 "clip_count": 47035,
69 "movie_id": 33832,
70 "link": "https://filmarks.com/movies/33832",
71 "production_year_link": "https://filmarks.com/list/year/2000s/2008",
72 "production_year": 2008,
73 "screening_date": "2008年08月09日",
74 "screening_time": "152分",
75 "country_of_origin": [
76 {
77 "name": "アメリカ",
78 "id": 5,
79 "link": "https://filmarks.com/list/country/5",
80 }
81 ],
82 "cast": [
83 {
84 "name": "クリスチャン・ベイル",
85 "character": "ブルース・ウェイン/バットマン",
86 "id": 179790,
87 "link": "https://filmarks.com/people/179790",
88 },
89 {
90 "name": "ヒース・レジャー",
91 "character": "ジョーカー",
92 "id": 96468,
93 "link": "https://filmarks.com/people/96468",
94 },
95 {
96 "name": "アーロン・エッカート",
97 "character": "ハービー・デント",
98 "id": 95575,
99 "link": "https://filmarks.com/people/95575",
100 },
101 {
102 "name": "マイケル・ケイン",
103 "character": "アルフレッド・ペニーワース",
104 "id": 129698,
105 "link": "https://filmarks.com/people/129698",
106 },
107 {
108 "name": "マギー・ギレンホール",
109 "character": "レイチェル・ドーズ",
110 "id": 76276,
111 "link": "https://filmarks.com/people/76276",
112 },
113 {
114 "name": "ゲイリー・オールドマン",
115 "character": "ジェームズ・“ジム”・ゴードン",
116 "id": 76854,
117 "link": "https://filmarks.com/people/76854",
118 },
119 {
120 "name": "モーガン・フリーマン",
121 "character": "ルーシャス・フォックス",
122 "id": 162058,
123 "link": "https://filmarks.com/people/162058",
124 },
125 {
126 "name": "モニーク・ガブリエラ・カーネン",
127 "character": "アンナ・ラミレス",
128 "id": 169378,
129 "link": "https://filmarks.com/people/169378",
130 },
131 {
132 "name": "ロン・ディーン",
133 "character": "マイケル・ワーツ",
134 "id": 168827,
135 "link": "https://filmarks.com/people/168827",
136 },
137 {
138 "name": "キリアン・マーフィ",
139 "character": "ジョナサン・クレイン",
140 "id": 32549,
141 "link": "https://filmarks.com/people/32549",
142 },
143 {
144 "name": "チン・ハン",
145 "character": "ラウ",
146 "id": 115241,
147 "link": "https://filmarks.com/people/115241",
148 },
149 {
150 "name": "ネスター・カーボネル",
151 "character": "アンソニー・ガルシア",
152 "id": 9875,
153 "link": "https://filmarks.com/people/9875",
154 },
155 {
156 "name": "エリック・ロバーツ",
157 "character": "サルバトーレ・マローニ",
158 "id": 32191,
159 "link": "https://filmarks.com/people/32191",
160 },
161 {
162 "name": "リッチー・コスター",
163 "character": "チェチェン人ボス",
164 "id": 17553,
165 "link": "https://filmarks.com/people/17553",
166 },
167 {
168 "name": "アンソニー・マイケル・ホール",
169 "character": "マイク・エンゲル",
170 "id": 157131,
171 "link": "https://filmarks.com/people/157131",
172 },
173 {
174 "name": "キース・ザラバッカ",
175 "character": "ジェラルド・スティーブンズ",
176 "id": 403,
177 "link": "https://filmarks.com/people/403",
178 },
179 {
180 "name": "コリン・マクファーレン",
181 "character": "ギリアン・B・ローブ",
182 "id": 166180,
183 "link": "https://filmarks.com/people/166180",
184 },
185 {
186 "name": "ジョシュア・ハート",
187 "character": "コールマン・リース",
188 "id": 138739,
189 "link": "https://filmarks.com/people/138739",
190 },
191 {
192 "name": "メリンダ・マックグロウ",
193 "character": "バーバラ・ゴードン",
194 "id": 118531,
195 "link": "https://filmarks.com/people/118531",
196 },
197 {
198 "name": "ネイサン・ギャンブル",
199 "character": "ジェームズ・“ジミー”・ゴードン・Jr",
200 "id": 58815,
201 "link": "https://filmarks.com/people/58815",
202 },
203 {
204 "name": "マイケル・ジェイ・ホワイト",
205 "character": "ギャンボル",
206 "id": 35406,
207 "link": "https://filmarks.com/people/35406",
208 },
209 {
210 "name": "ウィリアム・フィクナー",
211 "character": "銀行支店長",
212 "id": 4099,
213 "link": "https://filmarks.com/people/4099",
214 },
215 {
216 "name": "マシュー・オニール",
217 "character": "チャクルズ",
218 "id": 55502,
219 "link": "https://filmarks.com/people/55502",
220 },
221 {
222 "name": "エディソン・チャン",
223 "id": 74619,
224 "link": "https://filmarks.com/people/74619",
225 },
226 {
227 "name": "マイケル・ストヤノフ",
228 "character": "ドーピー",
229 "id": 159085,
230 "link": "https://filmarks.com/people/159085",
231 },
232 {
233 "name": "デヴィッド・ダストマルチャン",
234 "character": "トーマス・シフ",
235 "id": 191423,
236 "link": "https://filmarks.com/people/191423",
237 },
238 ],
239 },
240 ],
241)
242def test_info_with_results_single_1(client_nc, test_data, caplog) -> None:
243 movie_id = get_json_val(test_data, "$.movie_id")
245 resp = client_nc.get(f"/movies/{movie_id}")
246 resp_data = resp.json()
248 assert resp.status_code == 200
249 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
250 assert MOVIE_ENG in caplog.text
252 fields = [
253 "title",
254 "original_title",
255 "link",
256 "production_year_link",
257 "production_year",
258 "screening_date",
259 "screening_time",
260 "country_of_origin",
261 "cast",
262 ]
263 for field in fields:
264 assert get_json_val(resp_data, f"$.data.{field}") == get_json_val(test_data, f"$.{field}")
266 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
267 assert get_json_val(resp_data, "$.data.mark_count") >= get_json_val(test_data, "$.mark_count")
268 assert get_json_val(resp_data, "$.data.clip_count") >= get_json_val(test_data, "$.clip_count")
270 assert get_json_val(resp_data, "$.data.synopsis") is not None
271 assert get_json_val(resp_data, "$.data.official_site") is None
272 assert get_json_val(resp_data, "$.data.poster") is not None
273 assert get_json_val(resp_data, "$.data.genre") is not None
274 assert get_json_val(resp_data, "$.data.distributor") is not None
275 assert get_json_val(resp_data, "$.data.creator") is None
276 assert get_json_val(resp_data, "$.data.director") is not None
277 assert get_json_val(resp_data, "$.data.scriptwriter") is not None
278 assert get_json_val(resp_data, "$.data.artist") is None
281@pytest.mark.parametrize(
282 "test_data",
283 [
284 {
285 "title": "サバイバルファミリー",
286 "rating": 3.5,
287 "mark_count": 55551,
288 "clip_count": 13780,
289 "movie_id": 69153,
290 "link": "https://filmarks.com/movies/69153",
291 "production_year_link": "https://filmarks.com/list/year/2010s/2017",
292 "production_year": 2017,
293 "screening_date": "2017年02月11日",
294 "screening_time": "117分",
295 "country_of_origin": [
296 {
297 "name": "日本",
298 "id": 144,
299 "link": "https://filmarks.com/list/country/144",
300 }
301 ],
302 "cast": [
303 {
304 "name": "小日向文世",
305 "character": "鈴木義之",
306 "id": 51000,
307 "link": "https://filmarks.com/people/51000",
308 },
309 {
310 "name": "深津絵里",
311 "character": "鈴木光恵",
312 "id": 143090,
313 "link": "https://filmarks.com/people/143090",
314 },
315 {
316 "name": "泉澤祐希",
317 "character": "鈴木賢司",
318 "id": 186288,
319 "link": "https://filmarks.com/people/186288",
320 },
321 {
322 "name": "葵わかな",
323 "character": "鈴木結衣",
324 "id": 192162,
325 "link": "https://filmarks.com/people/192162",
326 },
327 {
328 "name": "菅原大吉",
329 "id": 163124,
330 "link": "https://filmarks.com/people/163124",
331 },
332 {
333 "name": "徳井優",
334 "id": 90668,
335 "link": "https://filmarks.com/people/90668",
336 },
337 {
338 "name": "桂雀々",
339 "id": 136172,
340 "link": "https://filmarks.com/people/136172",
341 },
342 {
343 "name": "森下能幸",
344 "id": 35127,
345 "link": "https://filmarks.com/people/35127",
346 },
347 {
348 "name": "田中要次",
349 "id": 154675,
350 "link": "https://filmarks.com/people/154675",
351 },
352 {
353 "name": "有福正志",
354 "id": 177514,
355 "link": "https://filmarks.com/people/177514",
356 },
357 {
358 "name": "左時枝",
359 "id": 55975,
360 "link": "https://filmarks.com/people/55975",
361 },
362 {
363 "name": "時任三郎",
364 "character": "斎藤敏夫",
365 "id": 108989,
366 "link": "https://filmarks.com/people/108989",
367 },
368 {
369 "name": "ミッキー・カーチス",
370 "id": 4258,
371 "link": "https://filmarks.com/people/4258",
372 },
373 {
374 "name": "藤原紀香",
375 "character": "斎藤静子",
376 "id": 122018,
377 "link": "https://filmarks.com/people/122018",
378 },
379 {
380 "name": "大野拓朗",
381 "character": "斎藤涼介",
382 "id": 64907,
383 "link": "https://filmarks.com/people/64907",
384 },
385 {
386 "name": "志尊淳",
387 "character": "斎藤翔平",
388 "id": 194173,
389 "link": "https://filmarks.com/people/194173",
390 },
391 {
392 "name": "渡辺えり",
393 "character": "古田富子",
394 "id": 91748,
395 "link": "https://filmarks.com/people/91748",
396 },
397 {
398 "name": "宅麻伸",
399 "character": "高橋亮三",
400 "id": 126115,
401 "link": "https://filmarks.com/people/126115",
402 },
403 {
404 "name": "柄本明",
405 "character": "佐々木重臣",
406 "id": 148053,
407 "link": "https://filmarks.com/people/148053",
408 },
409 {
410 "name": "大地康雄",
411 "character": "田中善一",
412 "id": 65017,
413 "link": "https://filmarks.com/people/65017",
414 },
415 ],
416 },
417 ],
418)
419def test_info_with_results_single_2(client_nc, test_data, caplog) -> None:
420 movie_id = get_json_val(test_data, "$.movie_id")
422 resp = client_nc.get(f"/movies/{movie_id}")
423 resp_data = resp.json()
425 assert resp.status_code == 200
426 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
427 assert MOVIE_ENG in caplog.text
429 fields = [
430 "title",
431 "link",
432 "production_year_link",
433 "production_year",
434 "screening_date",
435 "screening_time",
436 "country_of_origin",
437 "cast",
438 ]
439 for field in fields:
440 assert get_json_val(resp_data, f"$.data.{field}") == get_json_val(test_data, f"$.{field}")
442 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
443 assert get_json_val(resp_data, "$.data.mark_count") >= get_json_val(test_data, "$.mark_count")
444 assert get_json_val(resp_data, "$.data.clip_count") >= get_json_val(test_data, "$.clip_count")
446 assert get_json_val(resp_data, "$.data.original_title") is None
447 assert get_json_val(resp_data, "$.data.synopsis") is not None
448 assert get_json_val(resp_data, "$.data.official_site") is None
449 assert get_json_val(resp_data, "$.data.poster") is not None
450 assert get_json_val(resp_data, "$.data.genre") is not None
451 assert get_json_val(resp_data, "$.data.distributor") is not None
452 assert get_json_val(resp_data, "$.data.creator") is not None
453 assert get_json_val(resp_data, "$.data.director") is not None
454 assert get_json_val(resp_data, "$.data.scriptwriter") is not None
455 assert get_json_val(resp_data, "$.data.artist") is not None
458@pytest.mark.parametrize(
459 "test_data",
460 [
461 {
462 "title": "ハリー・ポッターと死の秘宝 PART1",
463 "original_title": "Harry Potter and the Deathly Hallows: Part 1",
464 "rating": 3.9,
465 "mark_count": 211876,
466 "clip_count": 12594,
467 "movie_id": 27701,
468 "link": "https://filmarks.com/movies/27701",
469 "production_year_link": "https://filmarks.com/list/year/2010s/2010",
470 "production_year": 2010,
471 "screening_date": "2010年11月19日",
472 "screening_time": "146分",
473 "country_of_origin": [
474 {
475 "name": "イギリス",
476 "id": 11,
477 "link": "https://filmarks.com/list/country/11",
478 },
479 {
480 "name": "アメリカ",
481 "id": 5,
482 "link": "https://filmarks.com/list/country/5",
483 },
484 ],
485 "cast": [
486 {
487 "name": "ダニエル・ラドクリフ",
488 "character": "ハリー・ポッター",
489 "id": 93709,
490 "link": "https://filmarks.com/people/93709",
491 },
492 {
493 "name": "ルパート・グリント",
494 "character": "ロン・ウィーズリー",
495 "id": 49543,
496 "link": "https://filmarks.com/people/49543",
497 },
498 {
499 "name": "エマ・ワトソン",
500 "character": "ハーマイオニー・グレンジャー",
501 "id": 181498,
502 "link": "https://filmarks.com/people/181498",
503 },
504 {
505 "name": "ヘレナ・ボナム=カーター",
506 "character": "ベラトリックス・レストレンジ",
507 "id": 172381,
508 "link": "https://filmarks.com/people/172381",
509 },
510 {
511 "name": "ロビー・コルトレーン",
512 "character": "ルビウス・ハグリッド",
513 "id": 133558,
514 "link": "https://filmarks.com/people/133558",
515 },
516 {
517 "name": "トム・フェルトン",
518 "character": "ドラコ・マルフォイ",
519 "id": 39284,
520 "link": "https://filmarks.com/people/39284",
521 },
522 {
523 "name": "レイフ・ファインズ",
524 "character": "ヴォルデモート",
525 "id": 53636,
526 "link": "https://filmarks.com/people/53636",
527 },
528 {
529 "name": "ブレンダン・グリーソン",
530 "character": "アラスター・ムーディ",
531 "id": 74009,
532 "link": "https://filmarks.com/people/74009",
533 },
534 {
535 "name": "リチャード・グリフィス",
536 "character": "バーノン・ダーズリー",
537 "id": 172595,
538 "link": "https://filmarks.com/people/172595",
539 },
540 {
541 "name": "ジョン・ハート",
542 "character": "オリバンダー老人",
543 "id": 141919,
544 "link": "https://filmarks.com/people/141919",
545 },
546 {
547 "name": "ジェイソン・アイザックス",
548 "character": "ルシウス・マルフォイ",
549 "id": 154590,
550 "link": "https://filmarks.com/people/154590",
551 },
552 {
553 "name": "ヘレン・マックロリー",
554 "character": "ナルシッサ・マルフォイ",
555 "id": 15531,
556 "link": "https://filmarks.com/people/15531",
557 },
558 {
559 "name": "ビル・ナイ",
560 "character": "ルーファス・スクリムジョール",
561 "id": 103981,
562 "link": "https://filmarks.com/people/103981",
563 },
564 {
565 "name": "ミランダ・リチャードソン",
566 "character": "リータ・スキーター",
567 "id": 69880,
568 "link": "https://filmarks.com/people/69880",
569 },
570 {
571 "name": "アラン・リックマン",
572 "character": "セブルス・スネイプ",
573 "id": 63940,
574 "link": "https://filmarks.com/people/63940",
575 },
576 {
577 "name": "ティモシー・スポール",
578 "character": "ピーター・ペティグリュー",
579 "id": 163849,
580 "link": "https://filmarks.com/people/163849",
581 },
582 {
583 "name": "イメルダ・スタウントン",
584 "character": "ドローレス・アンブリッジ",
585 "id": 131871,
586 "link": "https://filmarks.com/people/131871",
587 },
588 {
589 "name": "デヴィッド・シューリス",
590 "character": "リーマス・ルーピン",
591 "id": 120698,
592 "link": "https://filmarks.com/people/120698",
593 },
594 {
595 "name": "ジュリー・ウォルターズ",
596 "character": "モリー・ウィーズリー",
597 "id": 21241,
598 "link": "https://filmarks.com/people/21241",
599 },
600 {
601 "name": "ボニー・ライト",
602 "character": "ジニー・ウィーズリー",
603 "id": 56343,
604 "link": "https://filmarks.com/people/56343",
605 },
606 {
607 "name": "ジェームズ・フェルプス",
608 "character": "フレッド・ウィーズリー",
609 "id": 105900,
610 "link": "https://filmarks.com/people/105900",
611 },
612 {
613 "name": "オリヴァー・フェルプス",
614 "character": "ジョージ・ウィーズリー",
615 "id": 8433,
616 "link": "https://filmarks.com/people/8433",
617 },
618 {
619 "name": "サイモン・マクバーニー",
620 "character": "クリーチャー",
621 "id": 153912,
622 "link": "https://filmarks.com/people/153912",
623 },
624 {
625 "name": "ジョージ・ハリス",
626 "character": "キングズリー・シャックルボルト",
627 "id": 93989,
628 "link": "https://filmarks.com/people/93989",
629 },
630 {
631 "name": "イヴァナ・リンチ",
632 "character": "ルーナ・ラブグッド",
633 "id": 88775,
634 "link": "https://filmarks.com/people/88775",
635 },
636 {
637 "name": "マシュー・ルイス",
638 "character": "ネビル・ロングボトム",
639 "id": 151038,
640 "link": "https://filmarks.com/people/151038",
641 },
642 {
643 "name": "マーク・ウィリアムズ",
644 "character": "アーサー・ウィーズリー",
645 "id": 133352,
646 "link": "https://filmarks.com/people/133352",
647 },
648 {
649 "name": "ハリー・メリング",
650 "character": "ダドリー・ダーズリー",
651 "id": 154081,
652 "link": "https://filmarks.com/people/154081",
653 },
654 {
655 "name": "ナタリア・テナ",
656 "character": "ニンファドーラ・トンクス",
657 "id": 181255,
658 "link": "https://filmarks.com/people/181255",
659 },
660 {
661 "name": "クレマンス・ポエジー",
662 "character": "フラー・デラクール",
663 "id": 34868,
664 "link": "https://filmarks.com/people/34868",
665 },
666 {
667 "name": "デイヴ・レジーノ",
668 "id": 63516,
669 "link": "https://filmarks.com/people/63516",
670 },
671 {
672 "name": "ワーウィック・デイヴィス",
673 "id": 150297,
674 "link": "https://filmarks.com/people/150297",
675 },
676 {
677 "name": "フレディ・ストローマ",
678 "character": "コーマック・マクラーゲン",
679 "id": 49051,
680 "link": "https://filmarks.com/people/49051",
681 },
682 {
683 "name": "ピーター・マラン",
684 "character": "ヤックスリー",
685 "id": 1714,
686 "link": "https://filmarks.com/people/1714",
687 },
688 {
689 "name": "ガイ・ヘンリー",
690 "character": "パイアス・シックネス",
691 "id": 174548,
692 "link": "https://filmarks.com/people/174548",
693 },
694 {
695 "name": "ドーナル・グリーソン",
696 "character": "ビル・ウィーズリー",
697 "id": 144047,
698 "link": "https://filmarks.com/people/144047",
699 },
700 {
701 "name": "アンディ・リンデン",
702 "character": "マンダンガス・フレッチャー",
703 "id": 114138,
704 "link": "https://filmarks.com/people/114138",
705 },
706 {
707 "name": "リス・エヴァンス",
708 "character": "ゼノフィリウス・ラブグッド",
709 "id": 180121,
710 "link": "https://filmarks.com/people/180121",
711 },
712 {
713 "name": "デヴィッド・ライオール",
714 "character": "エルファイアス・ドージ",
715 "id": 96703,
716 "link": "https://filmarks.com/people/96703",
717 },
718 {
719 "name": "マッティエロック・ギブス",
720 "character": "ミュリエル・プルウェット",
721 "id": 108040,
722 "link": "https://filmarks.com/people/108040",
723 },
724 {
725 "name": "ニック・モラン",
726 "character": "スカビオール",
727 "id": 70470,
728 "link": "https://filmarks.com/people/70470",
729 },
730 {
731 "name": "ジェイミー・キャンベル・バウアー",
732 "character": "ゲラート・グリンデルバルド",
733 "id": 81369,
734 "link": "https://filmarks.com/people/81369",
735 },
736 {
737 "name": "キャロライン・ピクルズ",
738 "id": 91214,
739 "link": "https://filmarks.com/people/91214",
740 },
741 {
742 "name": "ミシェル・フェアリー",
743 "character": "グレンジャー夫人",
744 "id": 99116,
745 "link": "https://filmarks.com/people/99116",
746 },
747 {
748 "name": "アルバン・バイラクタライ",
749 "character": "アントニン・ドロホフ",
750 "id": 67294,
751 "link": "https://filmarks.com/people/67294",
752 },
753 {
754 "name": "レイド・サーベジヤ",
755 "id": 92697,
756 "link": "https://filmarks.com/people/92697",
757 },
758 {
759 "name": "フランク・ディレイン",
760 "character": "トム・マールヴォロ・リドル",
761 "id": 79409,
762 "link": "https://filmarks.com/people/79409",
763 },
764 {
765 "name": "ジム・ブロードベント",
766 "character": "ホラス・スラグホーン",
767 "id": 49884,
768 "link": "https://filmarks.com/people/49884",
769 },
770 {
771 "name": "マイケル・ガンボン",
772 "character": "アルバス・ダンブルドア",
773 "id": 39892,
774 "link": "https://filmarks.com/people/39892",
775 },
776 {
777 "name": "スカーレット・バーン",
778 "character": "パンジー・パーキンソン",
779 "id": 34797,
780 "link": "https://filmarks.com/people/34797",
781 },
782 ],
783 },
784 ],
785)
786def test_info_with_results_single_3(client_nc, test_data, caplog) -> None:
787 movie_id = get_json_val(test_data, "$.movie_id")
789 resp = client_nc.get(f"/movies/{movie_id}")
790 resp_data = resp.json()
792 assert resp.status_code == 200
793 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
794 assert MOVIE_ENG in caplog.text
796 fields = [
797 "title",
798 "original_title",
799 "link",
800 "production_year_link",
801 "production_year",
802 "screening_date",
803 "screening_time",
804 "country_of_origin",
805 "cast",
806 ]
807 for field in fields:
808 assert get_json_val(resp_data, f"$.data.{field}") == get_json_val(test_data, f"$.{field}")
810 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
811 assert get_json_val(resp_data, "$.data.mark_count") >= get_json_val(test_data, "$.mark_count")
812 assert get_json_val(resp_data, "$.data.clip_count") >= get_json_val(test_data, "$.clip_count")
814 assert get_json_val(resp_data, "$.data.synopsis") is not None
815 assert get_json_val(resp_data, "$.data.official_site") is None
816 assert get_json_val(resp_data, "$.data.poster") is not None
817 assert get_json_val(resp_data, "$.data.genre") is not None
818 assert get_json_val(resp_data, "$.data.distributor") is not None
819 assert get_json_val(resp_data, "$.data.creator") is not None
820 assert get_json_val(resp_data, "$.data.director") is not None
821 assert get_json_val(resp_data, "$.data.scriptwriter") is not None
822 assert get_json_val(resp_data, "$.data.artist") is None
825@pytest.mark.parametrize(
826 "test_data",
827 [
828 {
829 "title": "グランメゾン・パリ",
830 "rating": 3.8,
831 "mark_count": 29379,
832 "clip_count": 18394,
833 "movie_id": 116998,
834 "link": "https://filmarks.com/movies/116998",
835 "official_site": "https://grandmaison-project.jp",
836 "production_year_link": "https://filmarks.com/list/year/2020s/2024",
837 "production_year": 2024,
838 "screening_date": "2024年12月30日",
839 "screening_time": "117分",
840 "country_of_origin": [
841 {
842 "name": "日本",
843 "id": 144,
844 "link": "https://filmarks.com/list/country/144",
845 }
846 ],
847 "cast": [
848 {
849 "name": "木村拓哉",
850 "character": "尾花夏樹",
851 "id": 18417,
852 "link": "https://filmarks.com/people/18417",
853 },
854 {
855 "name": "鈴木京香",
856 "character": "早見倫子",
857 "id": 24282,
858 "link": "https://filmarks.com/people/24282",
859 },
860 {
861 "name": "オク・テギョン",
862 "character": "リック・ユアン",
863 "id": 193242,
864 "link": "https://filmarks.com/people/193242",
865 },
866 {
867 "name": "正門良規",
868 "character": "小暮佑",
869 "id": 244456,
870 "link": "https://filmarks.com/people/244456",
871 },
872 {
873 "name": "玉森裕太",
874 "character": "平古祥平",
875 "id": 127408,
876 "link": "https://filmarks.com/people/127408",
877 },
878 {
879 "name": "寛一郎",
880 "character": "芹田公一",
881 "id": 219445,
882 "link": "https://filmarks.com/people/219445",
883 },
884 {
885 "name": "吉谷彩子",
886 "character": "松井萌絵",
887 "id": 17247,
888 "link": "https://filmarks.com/people/17247",
889 },
890 {
891 "name": "中村アン",
892 "character": "久住栞奈",
893 "id": 210512,
894 "link": "https://filmarks.com/people/210512",
895 },
896 {
897 "name": "冨永愛",
898 "character": "リンダ・真知子・リシャール",
899 "id": 131180,
900 "link": "https://filmarks.com/people/131180",
901 },
902 {
903 "name": "及川光博",
904 "character": "相沢瓶人",
905 "id": 177749,
906 "link": "https://filmarks.com/people/177749",
907 },
908 {
909 "name": "沢村一樹",
910 "character": "京野陸太郎",
911 "id": 126120,
912 "link": "https://filmarks.com/people/126120",
913 },
914 ],
915 },
916 ],
917)
918def test_info_with_results_single_4(client_nc, test_data, caplog) -> None:
919 movie_id = get_json_val(test_data, "$.movie_id")
921 resp = client_nc.get(f"/movies/{movie_id}")
922 resp_data = resp.json()
924 assert resp.status_code == 200
925 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
926 assert MOVIE_ENG in caplog.text
928 fields = [
929 "title",
930 "link",
931 "official_site",
932 "production_year_link",
933 "production_year",
934 "screening_date",
935 "screening_time",
936 "country_of_origin",
937 "cast",
938 ]
939 for field in fields:
940 assert get_json_val(resp_data, f"$.data.{field}") == get_json_val(test_data, f"$.{field}")
942 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
943 assert get_json_val(resp_data, "$.data.mark_count") >= get_json_val(test_data, "$.mark_count")
944 assert get_json_val(resp_data, "$.data.clip_count") >= get_json_val(test_data, "$.clip_count")
946 assert get_json_val(resp_data, "$.data.synopsis") is not None
947 assert get_json_val(resp_data, "$.data.poster") is not None
948 assert get_json_val(resp_data, "$.data.genre") is not None
949 assert get_json_val(resp_data, "$.data.distributor") is not None
950 assert get_json_val(resp_data, "$.data.creator") is None
951 assert get_json_val(resp_data, "$.data.director") is not None
952 assert get_json_val(resp_data, "$.data.scriptwriter") is not None
953 assert get_json_val(resp_data, "$.data.artist") is None
956def test_info_with_results_random(client_nc, caplog) -> None:
957 with open(file="tests/movie/100_movies.json", mode="r", encoding="utf-8") as f:
958 test_data = json.load(f)
959 movie = choice(test_data)
961 title = get_json_val(movie, "$.title")
962 movie_id = get_json_val(movie, "$.id")
964 resp = client_nc.get(f"/movies/{movie_id}")
965 resp_data = resp.json()
967 assert resp.status_code == 200
968 assert MOVIE_ENG in caplog.text
969 assert get_json_val(resp_data, "$.data.title") == title
970 assert get_json_val(resp_data, "$.data.rating") is not None
971 assert get_json_val(resp_data, "$.data.mark_count") is not None
972 assert get_json_val(resp_data, "$.data.clip_count") is not None
973 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
974 assert get_json_val(resp_data, "$.data.link") is not None
977@pytest.mark.parametrize(
978 "test_data",
979 [
980 {
981 "title": "バットマン ビギンズ",
982 "original_title": "Batman Begins",
983 "rating": 3.8,
984 "movie_id": 22767,
985 "link": "https://filmarks.com/movies/22767",
986 "reviews": {
987 "user": {
988 "name": "shingo",
989 "id": "ZR5DnIWz",
990 "link": "https://filmarks.com/users/ZR5DnIWz",
991 },
992 "review": {
993 "date": "2012/08/11 12:01",
994 "rating": 3.8,
995 "id": 230,
996 "link": "https://filmarks.com/movies/22767/reviews/230",
997 "contents": "ダークナイトライジングに向けて復習。物語がバラバラしてる印象なんだけど、敵が悪としてではなくて自分たちの信じる正義を原理的に実行する人たちとして描かれてるのがよかった。",
998 },
999 },
1000 },
1001 ],
1002)
1003def test_review_with_results_full(client_nc, test_data, caplog) -> None:
1004 movie_id = get_json_val(test_data, "$.movie_id")
1006 slug = f"movies/{movie_id}"
1007 last_page = get_reviews_last_page(slug)
1009 resp = client_nc.get(f"{slug}/reviews?page={last_page}")
1010 resp_data = resp.json()
1012 assert resp.status_code == 200
1013 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
1014 assert MOVIE_ENG in caplog.text
1016 review_fields = [
1017 "user.name",
1018 "user.id",
1019 "user.link",
1020 "review.date",
1021 "review.rating",
1022 "review.id",
1023 "review.link",
1024 "review.contents"
1025 ]
1026 for field in review_fields:
1027 assert get_json_val(resp_data, f"$.data.reviews[-1].{field}") == get_json_val(test_data, f"$.reviews.{field}")
1029 assert get_json_val(resp_data, "$.data.title") == get_json_val(test_data, "$.title")
1030 assert get_json_val(resp_data, "$.data.original_title") == get_json_val(test_data, "$.original_title")
1031 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
1032 assert get_json_val(resp_data, "$.data.link") == f"{get_json_val(test_data, "$.link")}?page={last_page}"
1033 assert len(get_json_val(resp_data, "$.data.reviews")) > 0
1036@pytest.mark.parametrize(
1037 "test_data",
1038 [
1039 {
1040 "title": "バットマン ビギンズ",
1041 "rating": 3.8,
1042 "movie_id": 22767,
1043 "review_id": 230,
1044 "link": "https://filmarks.com/movies/22767/reviews/230",
1045 "review": {
1046 "user": {
1047 "name": "shingo",
1048 "id": "ZR5DnIWz",
1049 "link": "https://filmarks.com/users/ZR5DnIWz",
1050 },
1051 "review": {
1052 "date": "2012/08/11 12:01",
1053 "rating": 3.8,
1054 "contents": "ダークナイトライジングに向けて復習。物語がバラバラしてる印象なんだけど、敵が悪としてではなくて自分たちの信じる正義を原理的に実行する人たちとして描かれてるのがよかった。",
1055 },
1056 },
1057 },
1058 ],
1059)
1060def test_review_with_results_specific(client_nc, test_data, caplog) -> None:
1061 movie_id = get_json_val(test_data, "$.movie_id")
1062 review_id = get_json_val(test_data, "$.review_id")
1064 resp = client_nc.get(f"movies/{movie_id}/reviews/230")
1065 resp_data = resp.json()
1067 assert resp.status_code == 200
1068 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
1069 assert get_json_val(resp_data, "$.data.review_id") == review_id
1070 assert MOVIE_ENG in caplog.text
1072 review_fields = [
1073 "user.name",
1074 "user.id",
1075 "user.link",
1076 "review.date",
1077 "review.rating",
1078 "review.contents"
1079 ]
1080 for field in review_fields:
1081 assert get_json_val(resp_data, f"$.data.review.{field}") == get_json_val(test_data, f"$.review.{field}")
1083 assert get_json_val(resp_data, "$.data.title") == get_json_val(test_data, "$.title")
1084 assert get_json_val(resp_data, "$.data.rating") == pytest.approx(get_json_val(test_data, "$.rating"), abs=0.5)
1085 assert get_json_val(resp_data, "$.data.link") == get_json_val(test_data, "$.link")
1088def test_review_with_results(client_nc, caplog) -> None:
1089 title = "細い目"
1090 original_title = "SEPET/Chinese Eyes"
1091 movie_id = 27402
1093 resp = client_nc.get(f"/movies/{movie_id}/reviews")
1094 resp_data = resp.json()
1096 assert resp.status_code == 200
1097 assert MOVIE_ENG in caplog.text
1098 assert get_json_val(resp_data, "$.data.title") == title
1099 assert get_json_val(resp_data, "$.data.original_title") == original_title
1100 assert get_json_val(resp_data, "$.data.rating") is not None
1101 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
1102 assert get_json_val(resp_data, "$.data.link") is not None
1103 assert len(get_json_val(resp_data, "$.data.reviews")) > 0
1106def test_review_without_results(client_nc, caplog) -> None:
1107 title = "細い目"
1108 original_title = "SEPET/Chinese Eyes"
1109 movie_id = 27402
1111 resp = client_nc.get(f"/movies/{movie_id}/reviews?page=50")
1112 resp_data = resp.json()
1114 assert resp.status_code == 200
1115 assert MOVIE_ENG in caplog.text
1116 assert get_json_val(resp_data, "$.data.title") == title
1117 assert get_json_val(resp_data, "$.data.original_title") == original_title
1118 assert get_json_val(resp_data, "$.data.rating") is not None
1119 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
1120 assert get_json_val(resp_data, "$.data.link") is not None
1121 assert len(get_json_val(resp_data, "$.data.reviews")) == 0
1124def test_review_with_results_random(client_nc, caplog) -> None:
1125 with open(file="tests/movie/100_movies.json", mode="r", encoding="utf-8") as f:
1126 test_data = json.load(f)
1127 movie = choice(test_data)
1129 title = get_json_val(movie, "$.title")
1130 movie_id = get_json_val(movie, "$.id")
1132 resp = client_nc.get(f"/movies/{movie_id}/reviews")
1133 resp_data = resp.json()
1135 assert resp.status_code == 200
1136 assert MOVIE_ENG in caplog.text
1137 assert get_json_val(resp_data, "$.data.title") == title
1138 assert get_json_val(resp_data, "$.data.rating") is not None
1139 assert get_json_val(resp_data, "$.data.movie_id") == movie_id
1140 assert get_json_val(resp_data, "$.data.link") is not None
1141 assert len(get_json_val(resp_data, "$.data.reviews")) > 0