From ca1c7cdd3ebb067fd867eb5fecf1656abdf3c5c5 Mon Sep 17 00:00:00 2001 From: Razze Date: Thu, 30 May 2024 01:12:48 +0200 Subject: [PATCH] Add a test for movies with same name See for e.g. https://github.com/trakt/script.trakt/issues/480 --- tests/fixtures/movies_local_same_name.json | 38 +++++++++++++++++++ tests/fixtures/movies_local_same_name_2.json | 20 ++++++++++ .../movies_local_same_name_result.json | 20 ++++++++++ tests/test_utilities.py | 16 ++++++++ 4 files changed, 94 insertions(+) create mode 100644 tests/fixtures/movies_local_same_name.json create mode 100644 tests/fixtures/movies_local_same_name_2.json create mode 100644 tests/fixtures/movies_local_same_name_result.json diff --git a/tests/fixtures/movies_local_same_name.json b/tests/fixtures/movies_local_same_name.json new file mode 100644 index 00000000..9f9c837b --- /dev/null +++ b/tests/fixtures/movies_local_same_name.json @@ -0,0 +1,38 @@ +[ + { + "imdbnumber": "116853", + "movieid": 781, + "runtime": 5220, + "title": "The Bling Ring", + "userrating": 0, + "year": 2011, + "watched_at": "", + "collected_at": "2024-05-29T22:01:43+00:00", + "plays": 0, + "rating": 0, + "collected": 1, + "watched": 0, + "ids": { + "imdb": "tt1935749", + "tmdb": "116853" + } + }, + { + "imdbnumber": "96936", + "movieid": 782, + "runtime": 5400, + "title": "The Bling Ring", + "userrating": 0, + "year": 2013, + "watched_at": "", + "collected_at": "2024-05-29T22:01:43+00:00", + "plays": 0, + "rating": 0, + "collected": 1, + "watched": 0, + "ids": { + "imdb": "tt2132285", + "tmdb": "96936" + } + } +] \ No newline at end of file diff --git a/tests/fixtures/movies_local_same_name_2.json b/tests/fixtures/movies_local_same_name_2.json new file mode 100644 index 00000000..acbd1a3d --- /dev/null +++ b/tests/fixtures/movies_local_same_name_2.json @@ -0,0 +1,20 @@ +[ + { + "imdbnumber": "116853", + "movieid": 781, + "runtime": 5220, + "title": "The Bling Ring", + "userrating": 0, + "year": 2011, + "watched_at": "", + "collected_at": "2024-05-29T22:01:43+00:00", + "plays": 0, + "rating": 0, + "collected": 1, + "watched": 0, + "ids": { + "imdb": "tt1935749", + "tmdb": "116853" + } + } +] \ No newline at end of file diff --git a/tests/fixtures/movies_local_same_name_result.json b/tests/fixtures/movies_local_same_name_result.json new file mode 100644 index 00000000..39f5de28 --- /dev/null +++ b/tests/fixtures/movies_local_same_name_result.json @@ -0,0 +1,20 @@ +[ + { + "imdbnumber": "96936", + "movieid": 782, + "runtime": 5400, + "title": "The Bling Ring", + "userrating": 0, + "year": 2013, + "watched_at": "", + "collected_at": "2024-05-29T22:01:43+00:00", + "plays": 0, + "rating": 0, + "collected": 1, + "watched": 0, + "ids": { + "imdb": "tt2132285", + "tmdb": "96936" + } + } +] \ No newline at end of file diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 33afe974..8c86e185 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -267,6 +267,22 @@ def test_sanitizeMovies_userrating(): assert not result +def test_compareMovies_matchByTitleAndYear_titles_with_same_name_for_collection(): + data1 = load_params_from_json("tests/fixtures/movies_local_same_name.json") + + assert utilities.compareMovies(data1, "", True) == data1 + + +def test_compareMovies_matchByTitleAndYear_titles_with_same_name_for_collection_one_already_collected(): + data1 = load_params_from_json("tests/fixtures/movies_local_same_name.json") + data2 = load_params_from_json("tests/fixtures/movies_local_same_name_2.json") + result_json = load_params_from_json( + "tests/fixtures/movies_local_same_name_result.json" + ) + + assert utilities.compareMovies(data1, data2, True) == result_json + + def test_compareMovies_matchByTitleAndYear_collected_match(): data1 = load_params_from_json("tests/fixtures/movies_local.json") data2 = load_params_from_json("tests/fixtures/movies_remote.json")