add imdb full import mode
This commit is contained in:
parent
b5cb22822e
commit
7dd10f8bc3
17 changed files with 721 additions and 109 deletions
19
tests/test_imdb.py
Normal file
19
tests/test_imdb.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import pytest
|
||||
from unwind.imdb import imdb_rating_from_score, score_from_imdb_rating
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rating", (x / 10 for x in range(10, 101)))
|
||||
def test_rating_conversion(rating):
|
||||
assert rating == imdb_rating_from_score(score_from_imdb_rating(rating))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("score", range(0, 101))
|
||||
def test_score_conversion(score):
|
||||
# Because our score covers 101 discrete values and IMDb's rating only 91
|
||||
# discrete values, the mapping is non-injective, i.e. 10 values can't be
|
||||
# mapped uniquely.
|
||||
non_injective = set(range(5, 100, 10))
|
||||
if score in non_injective:
|
||||
pytest.skip(f"Score cannot be mapped back correctly: {score}")
|
||||
|
||||
assert score == score_from_imdb_rating(imdb_rating_from_score(score))
|
||||
Loading…
Add table
Add a link
Reference in a new issue