示例#1
0
def test_landsat_validFull(list_directory, session):
    """Should work as expected
    """

    path = os.path.join(os.path.dirname(__file__), f'fixtures/LC08_L1GT_178119_20180103_20180103_01_RT_MTL.json')
    with open(path, 'rb') as f:
        c1L8 = {'Body': BytesIO(f.read())}

    path = os.path.join(os.path.dirname(__file__), f'fixtures/LC81781192017016LGN00_MTL.json')
    with open(path, 'rb') as f:
        L8 = {'Body': BytesIO(f.read())}

    session.return_value.client.return_value.get_object.side_effect = [c1L8, L8]

    list_directory.side_effect = [
        ['c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/'],
        ['L8/178/119/LC81781192017016LGN00/']]

    path = '178'
    row = '119'
    full = True

    assert list(search.landsat(path, row, full))
    assert session.return_value.client.return_value.get_object.call_count == 2
    assert list_directory.call_count == 2
示例#2
0
def test_landsat_valid(list_directory, session):
    """Should work as expected
    """

    session.return_value.client.return_value.get_object.return_value = True

    list_directory.side_effect = [
        ['c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/'],
        ['L8/178/119/LC81781192017016LGN00/']]

    path = '178'
    row = '119'
    full = False

    assert list(search.landsat(path, row, full))
    session.return_value.client.return_value.get_object.assert_not_called()
    assert list_directory.call_count == 2
示例#3
0
def landsat(
    path,
    row,
    pathrow,
    full,
):
    """Landsat search CLI."""
    # TODO: add tests for pathrow and path+row options
    if pathrow:
        pr_info = [
            dict(path=x.split('-')[0], row=x.split('-')[1]) for x in pathrow
        ]
    else:
        pr_info = [dict(path=path, row=row)]

    for el in pr_info:
        for scene in search.landsat(**el, full=full):
            click.echo(json.dumps(scene))