diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..de5533f --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/pylast/__init__.py b/pylast/__init__.py index f7fe250..51bb5a1 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -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 diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 8962ef3..1574d13 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -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