Skip to content

Commit

Permalink
Schema test and final flake
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks committed Feb 19, 2014
1 parent 76c68fc commit 87ec873
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mopidy_tunein/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

TUNEIN_ID_PROGRAM = 'program'
TUNEIN_ID_STATION = 'station'
TUNEIN_ID_GROUP= 'group'
TUNEIN_ID_GROUP = 'group'
TUNEIN_ID_TOPIC = 'topic'
TUNEIN_ID_CATEGORY = 'category'
TUNEIN_ID_REGION = 'region'
Expand Down
19 changes: 9 additions & 10 deletions mopidy_tunein/tunein.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def _memoized(*args):
value = func(*args)
self.cache[args] = (value, now)
return value

except TypeError:
return func(*args) # uncachable
return func(*args)

def clear():
self.cache.clear()

Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, timeout):
self._base_uri = 'http://opml.radiotime.com/%s'
self._timeout = timeout / 1000.0
self._stations = {}

def reload(self):
self._stations.clear()
self._tunein.clear()
Expand Down Expand Up @@ -165,7 +165,7 @@ def categories(self, category=''):
def locations(self, location):
args = '&id=' + location
results = self._tunein('Browse.ashx', args)
# TODO: Support filters here
# TODO: Support filters here
return [x for x in results if 'guide_id' in x]

def _browse(self, section_name, guide_id):
Expand All @@ -186,7 +186,7 @@ def related(self, guide_id):
return self._browse('Related', guide_id)

def shows(self, guide_id):
return self._browse('Show', guide_id)#
return self._browse('Show', guide_id)

def episodes(self, guide_id):
args = '&c=pbrowse&id=' + guide_id
Expand All @@ -211,13 +211,12 @@ def parse_stream_url(self, url):
logger.debug('Using tunein stream url parsing')
extension = urlparse.urlparse(url).path[-4:]
if extension in ['.mp3', '.wma']:
# Catch these easy ones
return [url]
return [url] # Catch these easy ones
results = []
playlist, content_type = self._get_playlist(url)
if playlist:
parser = find_playlist_parser(extension, content_type)
if parser:
if parser:
playlist_data = StringIO.StringIO(playlist)
results = [u for u in parser(playlist_data) if u is not None]

Expand Down Expand Up @@ -269,7 +268,7 @@ def _tunein(self, variant, args):
data = response.json()
if (data['head']['status'] != '200'):
raise requests.exceptions.HTTPError(data['head']['status'],
data['head']['fault'])
data['head']['fault'])
return data['body']
except Exception as e:
logger.error('Tunein request failed: %s', e)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def test_get_config_schema(self):

schema = ext.get_config_schema()

# TODO Test the content of your config schema
#self.assertIn('username', schema)
#self.assertIn('password', schema)
self.assertIn('timeout', schema)

# TODO Write more tests

0 comments on commit 87ec873

Please sign in to comment.