Repository: andycasey/ads

Issue:
Number of returned results doesn't correspond to 'rows' key value in SearchQuery
Example code:
````
In [5]: papers = ads.SearchQuery(q="supernova", sort="citation_count", rows=10)  
In [6]: print(len(list(papers)))
40
````
Not massively important, but a bit surprising anyway. Any explanation? Thanks!

Discussion:

Patch:
diff --git a/ads/search.py b/ads/search.py
index eb64e70..fed6c0c 100644
--- a/ads/search.py
+++ b/ads/search.py
@@ -275,7 +275,7 @@ class SearchQuery(BaseQuery):
                       "title", "reference", "citation"]
 
     def __init__(self, query_dict=None, q=None, fq=None, fl=DEFAULT_FIELDS,
-                 sort=None, start=0, rows=50, max_pages=3, **kwargs):
+                 sort=None, start=0, rows=50, max_pages=1, **kwargs):
         """
         constructor
         :param query_dict: raw query that will be sent unmodified. raw takes
@@ -288,7 +288,7 @@ class SearchQuery(BaseQuery):
         :param start: solr "start" param (start)
         :param rows: solr "rows" param (rows)
         :param max_pages: Maximum number of pages to return. This value may
-            be modified after instansiation to increase the number of results
+            be modified after instantiation to increase the number of results
         :param kwargs: kwargs to add to `q` as "key:value"
         """
         self._articles = []
@@ -385,7 +385,7 @@ class SearchQuery(BaseQuery):
 
             # if we have hit the max_pages limit, then iteration is done.
             page = math.ceil(len(self.articles)/self.query['rows'])
-            if page > self.max_pages:
+            if page >= self.max_pages:
                 raise StopIteration("Maximum number of pages queried")
 
             # We aren't on the max_page of results nor do we have all


Test patch:
diff --git a/ads/tests/test_search.py b/ads/tests/test_search.py
index 346d957..331a9f5 100644
--- a/ads/tests/test_search.py
+++ b/ads/tests/test_search.py
@@ -131,18 +131,24 @@ class TestSearchQuery(unittest.TestCase):
             self.assertEqual(len(sq.articles), 1)
             self.assertEqual(sq._query['start'], 1)
             self.assertEqual(next(sq).bibcode, '2012GCN..13229...1S')
-            self.assertEqual(len(list(sq)), 19)  # 2 already returned
+            self.assertEqual(len(list(sq)), 18)  # 2 already returned
             with self.assertRaisesRegexp(
                     StopIteration,
                     "Maximum number of pages queried"):
                 next(sq)
             sq.max_pages = 500
-            self.assertEqual(len(list(sq)), 28-19-2)
+            self.assertEqual(len(list(sq)), 28-18-2)
             with self.assertRaisesRegexp(
                     StopIteration,
                     "All records found"):
                 next(sq)
 
+        # not setting max_pages should return the exact number of rows requests
+        sq = SearchQuery(q="unittest", rows=3)
+        with MockSolrResponse(sq.HTTP_ENDPOINT):
+            self.assertEqual(len(list(sq)), 3)
+
+
     def test_init(self):
         """
         init should result in a properly formatted query attribute