Repository: planetlabs/planet-client-python

Issue:
planet orders list cli command should return sequence
Change `planet orders list` cli command to return a sequence of json descriptions of the orders instead of a list.

something like...
```
async def list(ctx, state, limit, pretty):
    '''List orders

    This command prints a sequence of the returned order descriptions,
    optionally pretty-printed.
    '''
    async with orders_client(ctx) as cl:
        orders = await cl.list_orders(state=state, limit=limit)
        async for o in orders:
            echo_json(o, pretty)
        # orders_list = [o async for o in orders]
    # echo_json(orders_list, pretty)
```

Comments:

Patch:
diff --git a/planet/cli/orders.py b/planet/cli/orders.py
index a290c63..90b7f47 100644
--- a/planet/cli/orders.py
+++ b/planet/cli/orders.py
@@ -71,8 +71,8 @@ async def list(ctx, state, limit, pretty):
     '''
     async with orders_client(ctx) as cl:
         orders = await cl.list_orders(state=state, limit=limit)
-        orders_list = [o async for o in orders]
-    echo_json(orders_list, pretty)
+        async for o in orders:
+            echo_json(o, pretty)
 
 
 @orders.command()


Test patch:
diff --git a/tests/integration/test_orders_cli.py b/tests/integration/test_orders_cli.py
index 38275c6..3afce4a 100644
--- a/tests/integration/test_orders_cli.py
+++ b/tests/integration/test_orders_cli.py
@@ -72,8 +72,9 @@ def test_cli_orders_list_basic(invoke, order_descriptions):
     respx.get(next_page_url).return_value = mock_resp2
 
     result = invoke(['list'])
-    assert not result.exception
-    assert json.dumps([order1, order2, order3]) + '\n' == result.output
+    assert result.exit_code == 0
+    sequence = '\n'.join([json.dumps(o) for o in [order1, order2, order3]])
+    assert result.output == sequence + '\n'
 
 
 @respx.mock
@@ -83,8 +84,8 @@ def test_cli_orders_list_empty(invoke):
     respx.get(TEST_ORDERS_URL).return_value = mock_resp
 
     result = invoke(['list'])
-    assert not result.exception
-    assert [] == json.loads(result.output)
+    assert result.exit_code == 0
+    assert result.output == ''
 
 
 @respx.mock
@@ -104,8 +105,9 @@ def test_cli_orders_list_state(invoke, order_descriptions):
     # if the value of state doesn't get sent as a url parameter,
     # the mock will fail and this test will fail
     result = invoke(['list', '--state', 'failed'])
-    assert not result.exception
-    assert [order1, order2] == json.loads(result.output)
+    assert result.exit_code == 0
+    sequence = '\n'.join([json.dumps(o) for o in [order1, order2]])
+    assert result.output == sequence + '\n'
 
 
 @respx.mock
@@ -137,8 +139,9 @@ def test_cli_orders_list_limit(invoke,
     respx.get(TEST_ORDERS_URL).return_value = mock_resp
 
     result = invoke(['list', '--limit', limit])
-    assert not result.exception
-    assert len(json.loads(result.output)) == limited_list_length
+    assert result.exit_code == 0
+    count = len(result.output.strip().split('\n'))
+    assert count == limited_list_length
 
 
 @respx.mock
@@ -155,8 +158,8 @@ def test_cli_orders_list_pretty(invoke, monkeypatch, order_description):
     respx.get(TEST_ORDERS_URL).return_value = mock_resp
 
     result = invoke(['list', '--pretty'])
-    assert not result.exception
-    mock_echo_json.assert_called_once_with([order_description], True)
+    assert result.exit_code == 0
+    mock_echo_json.assert_called_once_with(order_description, True)
 
 
 # TODO: add tests for "get --pretty" (gh-491).