Merge pull request #230 from pylast/fix-search-total
Fix search.get_total_result_count()
This commit is contained in:
commit
3a7cc9c410
2
COPYING
2
COPYING
|
@ -1,6 +1,6 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
|
|
|
@ -830,7 +830,7 @@ class _Request(object):
|
|||
|
||||
try:
|
||||
conn.request(
|
||||
method='POST', url="http://" + HOST_NAME + HOST_SUBDIR,
|
||||
method='POST', url="https://" + HOST_NAME + HOST_SUBDIR,
|
||||
body=data, headers=headers)
|
||||
except Exception as e:
|
||||
raise NetworkError(self.network, e)
|
||||
|
@ -2483,7 +2483,7 @@ class _Search(_BaseObject):
|
|||
|
||||
doc = self._request(self._ws_prefix + ".search", True)
|
||||
|
||||
return _extract(doc, "opensearch:totalResults")
|
||||
return _extract(doc, "totalResults")
|
||||
|
||||
def _retrieve_page(self, page_index):
|
||||
"""Returns the node of matches to be processed"""
|
||||
|
|
|
@ -213,7 +213,7 @@ class TestPyLastArtist(PyLastTestCase):
|
|||
name_cap = artist1.get_name(properly_capitalized=True)
|
||||
|
||||
# Assert
|
||||
self.assertIn("http", image)
|
||||
self.assertIn("https", image)
|
||||
self.assertGreater(playcount, 1)
|
||||
self.assertTrue(artist1 != artist2)
|
||||
self.assertEqual(name.lower(), name_cap.lower())
|
||||
|
|
|
@ -339,6 +339,18 @@ class TestPyLastNetwork(PyLastTestCase):
|
|||
self.assertIsInstance(results, list)
|
||||
self.assertIsInstance(results[0], pylast.Track)
|
||||
|
||||
def test_search_get_total_result_count(self):
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
track = "Smells Like Teen Spirit"
|
||||
search = self.network.search_for_track(artist, track)
|
||||
|
||||
# Act
|
||||
total = search.get_total_result_count()
|
||||
|
||||
# Assert
|
||||
self.assertGreater(int(total), 10000)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(failfast=True)
|
||||
|
|
Loading…
Reference in a new issue