Commit a26248ab authored by richardARPANET's avatar richardARPANET

Bugfix for issue in ``ImdbFacade.get_title`` where ``TypeError`` would raise...

Bugfix for issue in ``ImdbFacade.get_title`` where ``TypeError`` would raise if the Title did not have any genres.
parent 8a3d5430
Pipeline #132 failed with stage
in 10 minutes and 34 seconds
......@@ -6,7 +6,7 @@ Release History
5.6.2 (unreleased)
++++++++++++++++++
- Nothing changed yet.
- Bugfix for issue in ``ImdbFacade.get_title`` where ``TypeError`` would raise if the Title did not have any genres.
5.6.1 (2018-06-17)
......
......@@ -10,4 +10,4 @@ norecursedirs = .git
[flake8]
exclude = .git,__pycache__,legacy,build,dist,.tox
max-complexity = 13
max-complexity = 15
......@@ -192,7 +192,10 @@ class ImdbFacade(object):
writers = self._get_writers(top_crew_data)
directors = self._get_directors(top_crew_data)
creators = self._get_creators(top_crew_data)
genres = tuple(g.lower() for g in title_aux_data['genres'])
try:
genres = tuple(g.lower() for g in title_aux_data.get('genres'))
except TypeError:
genres = ()
credits = self._get_credits(credits_data)
try:
......
......@@ -45,15 +45,20 @@ class TestGetTitle(object):
assert title.episodes[-1].imdb_id
assert title.episodes[10].imdb_id
def test_movie(self, facade):
tv_show_imdb_id = 'tt0468569'
title = facade.get_title(imdb_id=tv_show_imdb_id)
@pytest.mark.parametrize('movie_imdb_id', [
'tt0468569',
'tt0017587',
])
def test_movie(self, facade, movie_imdb_id):
title = facade.get_title(imdb_id=movie_imdb_id)
assert isinstance(title, Title)
_check_title(title=title, facade=facade)
assert title.type == 'movie'
assert title.imdb_id == movie_imdb_id
assert len(title.episodes) == 0
assert isinstance(title.runtime, int)
assert title.runtime > 0
assert isinstance(title.runtime, (int, type(None)))
if title.runtime is not None:
assert title.runtime > 0
@pytest.mark.parametrize('imdb_id', [
'tt0795176',
......@@ -210,9 +215,9 @@ def _check_title(title, facade):
for genre in title.genres:
assert isinstance(genre, six.string_types)
assert isinstance(title.certification, six.string_types)
assert isinstance(title.certification, (six.string_types, type(None)))
assert title.image
assert isinstance(title.image.url, six.string_types)
assert isinstance(title.image.width, int)
assert isinstance(title.image.height, int)
if title.image:
assert isinstance(title.image.url, six.string_types)
assert isinstance(title.image.width, int)
assert isinstance(title.image.height, int)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment