Skip to content

Commit

Permalink
Add a test for movies with same name
Browse files Browse the repository at this point in the history
See for e.g. #480
  • Loading branch information
razzeee committed May 29, 2024
1 parent 86af16f commit ca1c7cd
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/fixtures/movies_local_same_name.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
20 changes: 20 additions & 0 deletions tests/fixtures/movies_local_same_name_2.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
20 changes: 20 additions & 0 deletions tests/fixtures/movies_local_same_name_result.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
16 changes: 16 additions & 0 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ca1c7cd

Please sign in to comment.