Commit b73fb280 authored by richardARPANET's avatar richardARPANET

Bugfix for issue in ``ImdbFacade.get_title`` where with titles which no do yet...

Bugfix for issue in ``ImdbFacade.get_title`` where with titles which no do yet have credits information would cause ``KeyError`` to raise.
parent 5cc49477
Pipeline #123 passed with stage
in 17 minutes and 16 seconds
...@@ -6,7 +6,7 @@ Release History ...@@ -6,7 +6,7 @@ Release History
5.6.1 (unreleased) 5.6.1 (unreleased)
++++++++++++++++++ ++++++++++++++++++
- Nothing changed yet. - Bugfix for issue in ``ImdbFacade.get_title`` where with titles which no do yet have credits information would cause ``KeyError`` to raise.
5.6.0 (2018-06-09) 5.6.0 (2018-06-09)
......
...@@ -140,7 +140,7 @@ class ImdbFacade(object): ...@@ -140,7 +140,7 @@ class ImdbFacade(object):
def _get_credits(self, credits_data): def _get_credits(self, credits_data):
credits = [] credits = []
for category in credits_data['credits']: for category in credits_data.get('credits', ()):
for item in credits_data['credits'][category]: for item in credits_data['credits'][category]:
credits.append(TitleName( credits.append(TitleName(
name=item['name'], name=item['name'],
......
...@@ -80,13 +80,16 @@ class TestGetTitle(object): ...@@ -80,13 +80,16 @@ class TestGetTitle(object):
if num_checked > 5: if num_checked > 5:
break break
def test_tv_episode(self, facade): @pytest.mark.parametrize('episode_imdb_id', [
episode_imdb_id = 'tt4847050' 'tt4847050',
'tt4849022',
])
def test_tv_episode(self, facade, episode_imdb_id):
title = facade.get_title(imdb_id=episode_imdb_id) title = facade.get_title(imdb_id=episode_imdb_id)
assert isinstance(title, Title) assert isinstance(title, Title)
assert isinstance(title.runtime, int)
assert title.runtime > 0 assert isinstance(title.runtime, (int, type(None)))
assert title.imdb_id == episode_imdb_id assert title.imdb_id == episode_imdb_id
assert len(title.episodes) == 0 assert len(title.episodes) == 0
assert isinstance(title.season, int) assert isinstance(title.season, 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