Repository: planetlabs/planet-client-python
Pull request #68 (2015-08-21 12:33:45)

Fixes


Patch:
diff --git a/planet/api/client.py b/planet/api/client.py
index eaf88d6..626e16f 100644
--- a/planet/api/client.py
+++ b/planet/api/client.py
@@ -99,14 +99,14 @@ class Client(object):
 
         .. todo:: Generalize to accept multiple scene ids.
         """
-        return self._get('scenes/%s/%s/' % (scene_type, scene_id)).get_body()
+        return self._get('scenes/%s/%s' % (scene_type, scene_id)).get_body()
 
     def fetch_scene_geotiffs(self, scene_ids, scene_type='ortho',
                              product='visual', callback=None):
         params = {
             'product': product
         }
-        paths = ['scenes/%s/%s/full/' % (scene_type, id) for id in scene_ids]
+        paths = ['scenes/%s/%s/full' % (scene_type, id) for id in scene_ids]
         return self._download_many(paths, params, callback)
 
     def fetch_scene_thumbnails(self, scene_ids, scene_type='ortho', size='md',
@@ -115,7 +115,7 @@ class Client(object):
             'size': size,
             'format': fmt
         }
-        paths = ['scenes/%s/%s/thumb/' % (scene_type, id) for id in scene_ids]
+        paths = ['scenes/%s/%s/thumb' % (scene_type, id) for id in scene_ids]
         return self._download_many(paths, params, callback)
 
     def list_mosaics(self):
@@ -156,7 +156,7 @@ class Client(object):
         return self._get(path, models.Quads, params).get_body()
 
     def fetch_mosaic_quad_geotiffs(self, mosaic_name, quad_ids, callback=None):
-        pt = 'mosaics/%s/quads/%s/full/'
+        pt = 'mosaics/%s/quads/%s/full'
         paths = [pt % (mosaic_name, qid) for qid in quad_ids]
         return self._download_many(paths, {}, callback)
 
diff --git a/planet/api/models.py b/planet/api/models.py
index 9bfb441..4878e83 100644
--- a/planet/api/models.py
+++ b/planet/api/models.py
@@ -163,8 +163,9 @@ class _Paged(JSON):
         return items
 
     def _json_stream(self, limit):
+        items = self.get()[self.ITEM_KEY]
         # if there are no results, the GeneratorAdapter doesn't play well
-        if self.get().get('count', 0):
+        if len(items):
             items = GeneratorAdapter(self.items_iter(limit))
         else:
             items = []
@@ -177,7 +178,10 @@ class _Features(_Paged):
 
     def _json_stream(self, limit):
         stream = super(_Features, self)._json_stream(limit)
-        stream['count'] = self.get()['count']
+        json_body = self.get()
+        # patch back in the count if present
+        if 'count' in json_body:
+            stream['count'] = json_body.get('count')
         stream['type'] = 'FeatureCollection'
         return stream
 
diff --git a/planet/scripts/__init__.py b/planet/scripts/__init__.py
index 3907cf1..44dc8d5 100644
--- a/planet/scripts/__init__.py
+++ b/planet/scripts/__init__.py
@@ -380,11 +380,11 @@ def sync(destination, workspace, scene_type, limit, dryrun):
 @pretty
 @limit_option(default=50)
 @cli.command('mosaics')
-def list_mosaics(pretty):
+def list_mosaics(limit, pretty):
     """
     List all mosaics
     """
-    echo_json_response(call_and_wrap(client().list_mosaics), pretty)
+    echo_json_response(call_and_wrap(client().list_mosaics), pretty, limit)
 
 
 @pretty


Test patch:
diff --git a/tests/test_mod.py b/tests/test_mod.py
index e442469..3a491f2 100644
--- a/tests/test_mod.py
+++ b/tests/test_mod.py
@@ -88,7 +88,7 @@ def test_status_code_other(client):
 def test_fetch_scene_info_scene_id(client):
     '''Verify get_scene_metadata path handling'''
     with requests_mock.Mocker() as m:
-        uri = os.path.join(client.base_url, 'scenes/ortho/x22/')
+        uri = os.path.join(client.base_url, 'scenes/ortho/x22')
         m.get(uri, text='bananas', status_code=200)
         assert client.get_scene_metadata('x22').get_raw() == 'bananas'