Merge pull request #129 from hugovk/develop
Network.get_top_tags: don't compare to limit if limit is None
This commit is contained in:
commit
a0256faa4e
13
.editorconfig
Normal file
13
.editorconfig
Normal file
|
@ -0,0 +1,13 @@
|
|||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
# 4 space indentation
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
|
@ -4,7 +4,7 @@
|
|||
# A Python interface to Last.fm (and other API compatible social networks)
|
||||
#
|
||||
# Copyright 2008-2010 Amr Hassan
|
||||
# Copyright 2013-2014 hugovk
|
||||
# Copyright 2013-2015 hugovk
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -34,7 +34,7 @@ import six
|
|||
|
||||
__version__ = '1.1.0'
|
||||
__author__ = 'Amr Hassan, hugovk'
|
||||
__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2014 hugovk"
|
||||
__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2015 hugovk"
|
||||
__license__ = "apache2"
|
||||
__email__ = 'amr.hassan@gmail.com'
|
||||
|
||||
|
@ -396,7 +396,7 @@ class _Network(object):
|
|||
|
||||
seq = []
|
||||
for node in doc.getElementsByTagName("tag"):
|
||||
if len(seq) >= limit:
|
||||
if limit and len(seq) >= limit:
|
||||
break
|
||||
tag = Tag(_extract(node, "name"), self)
|
||||
weight = _number(_extract(node, "count"))
|
||||
|
@ -4038,7 +4038,7 @@ def _extract(node, name, index=0):
|
|||
return None
|
||||
|
||||
|
||||
def _extract_element_tree(node, index=0):
|
||||
def _extract_element_tree(node):
|
||||
"""Extract an element tree into a multi-level dictionary
|
||||
|
||||
NB: If any elements have text nodes as well as nested
|
||||
|
@ -4197,13 +4197,13 @@ class BadSessionError(ScrobblingError):
|
|||
|
||||
class _ScrobblerRequest(object):
|
||||
|
||||
def __init__(self, url, params, network, type="POST"):
|
||||
def __init__(self, url, params, network, request_type="POST"):
|
||||
|
||||
for key in params:
|
||||
params[key] = str(params[key])
|
||||
|
||||
self.params = params
|
||||
self.type = type
|
||||
self.type = request_type
|
||||
(self.hostname, self.subdir) = url_split_host(url[len("http:"):])
|
||||
self.network = network
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def load_secrets():
|
|||
return doc
|
||||
|
||||
|
||||
@flaky
|
||||
@flaky(max_runs=5, min_passes=1)
|
||||
class TestPyLast(unittest.TestCase):
|
||||
|
||||
secrets = None
|
||||
|
@ -1101,6 +1101,14 @@ class TestPyLast(unittest.TestCase):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(tags, pylast.Tag)
|
||||
|
||||
def test_network_get_top_tags_with_no_limit(self):
|
||||
# Arrange
|
||||
# Act
|
||||
tags = self.network.get_top_tags()
|
||||
|
||||
# Assert
|
||||
self.helper_at_least_one_thing_in_top_list(tags, pylast.Tag)
|
||||
|
||||
def test_network_get_top_tracks_with_limit(self):
|
||||
# Arrange
|
||||
# Act
|
||||
|
@ -1228,7 +1236,7 @@ class TestPyLast(unittest.TestCase):
|
|||
self.helper_dates_valid(dates)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_get_assert_charts(lastfm_user, dates[1])
|
||||
self.helper_get_assert_charts(lastfm_user, dates[0])
|
||||
|
||||
def test_track_top_fans(self):
|
||||
# Arrange
|
||||
|
|
Loading…
Reference in a new issue