Beispiel #1
0
def test_get_l8_info_validC1(get_object):
    """Should work as expected
    """

    scene_id = 'LC08_L1GT_178119_20180103_20180103_01_RT'
    full = False
    s3 = None

    expected = {
        'acquisition_date': '20180103',
        'browseURL':
            'https://landsat-pds.s3.amazonaws.com/c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT_thumb_large.jpg',
        'category': 'RT',
        'collection': '01',
        'correction_level': 'L1GT',
        'ingestion_date': '20180103',
        'key': 'c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT',
        'path': '178',
        'row': '119',
        'satellite': 'L8',
        'scene_id': 'LC08_L1GT_178119_20180103_20180103_01_RT',
        'sensor': 'C',
        'thumbURL':
            'https://landsat-pds.s3.amazonaws.com/c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT_thumb_small.jpg'}

    assert search.get_l8_info(scene_id, full, s3) == expected
    get_object.assert_not_called()
Beispiel #2
0
def test_get_l8_info_botoError(get_object):
    """Should work as expected
    """

    get_object.side_effect = ClientError(
        {'Error': {'Code': 500, 'Message': 'Error'}}, 'get_object')

    scene_id = 'LC81782462014232LGN00'
    full = True
    s3 = None

    expected = {
        'acquisitionJulianDay': '232',
        'acquisitionYear': '2014',
        'acquisition_date': '20140820',
        'archiveVersion': '00',
        'browseURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_large.jpg',
        'category': 'pre',
        'groundStationIdentifier': 'LGN',
        'key': 'L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00',
        'path': '178',
        'row': '246',
        'satellite': 'L8',
        'scene_id': 'LC81782462014232LGN00',
        'sensor': 'C',
        'thumbURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_small.jpg'}

    assert search.get_l8_info(scene_id, full, s3) == expected
    get_object.assert_called_once()
Beispiel #3
0
def test_get_l8_info_valid(get_object):
    """Should work as expected
    """

    scene_id = 'LC81782462014232LGN00'
    full = False
    s3 = None

    expected = {
        'acquisitionJulianDay': '232',
        'acquisitionYear': '2014',
        'acquisition_date': '20140820',
        'archiveVersion': '00',
        'browseURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_large.jpg',
        'category': 'pre',
        'groundStationIdentifier': 'LGN',
        'key': 'L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00',
        'path': '178',
        'row': '246',
        'satellite': 'L8',
        'scene_id': 'LC81782462014232LGN00',
        'sensor': 'C',
        'thumbURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_small.jpg'}

    assert search.get_l8_info(scene_id, full, s3) == expected
    get_object.assert_not_called()
Beispiel #4
0
def test_get_l8_info_validFull(get_object):
    """Should work as expected
    """

    path = os.path.join(os.path.dirname(__file__), f'fixtures/LC81782462014232LGN00_MTL.json')
    with open(path, 'rb') as f:
        tileInfo = f.read()

    get_object.return_value = tileInfo

    scene_id = 'LC81782462014232LGN00'
    full = True
    s3 = None

    expected = {
        'acquisitionJulianDay': '232',
        'acquisitionYear': '2014',
        'acquisition_date': '20140820',
        'archiveVersion': '00',
        'browseURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_large.jpg',
        'category': 'pre',
        'cloud_coverage': 38.13,
        'cloud_coverage_land': 50.55,
        'geometry': {
            'coordinates': [[
                [100.4436, 82.63078],
                [86.61133, 82.64704],
                [87.8273, 80.91159],
                [99.02993, 80.89847],
                [100.4436, 82.63078]]],
            'type': 'Polygon'},
        'groundStationIdentifier': 'LGN',
        'key': 'L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00',
        'path': '178',
        'row': '246',
        'satellite': 'L8',
        'scene_id': 'LC81782462014232LGN00',
        'sensor': 'C',
        'sun_azimuth': -115.79513548,
        'sun_elevation': 16.11011632,
        'thumbURL':
            'https://landsat-pds.s3.amazonaws.com/L8/178/246/LC81782462014232LGN00/LC81782462014232LGN00_thumb_small.jpg'}

    assert search.get_l8_info(scene_id, full, s3) == expected
    get_object.assert_called_once()
Beispiel #5
0
def test_get_l8_info_validFullc1(get_object):
    """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:
        tileInfo = f.read()

    get_object.return_value = tileInfo

    scene_id = 'LC08_L1GT_178119_20180103_20180103_01_RT'
    full = True
    s3 = None

    expected = {
        'acquisition_date': '20180103',
        'browseURL':
            'https://landsat-pds.s3.amazonaws.com/c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT_thumb_large.jpg',
        'category': 'RT',
        'cloud_coverage': 64.66,
        'cloud_coverage_land': 64.66,
        'collection': '01',
        'correction_level': 'L1GT',
        'geometry': {
            'coordinates': [[
                [-36.27662, -80.68672],
                [-45.77772, -79.24248],
                [-55.38046, -80.6257],
                [-45.97596, -82.33114],
                [-36.27662, -80.68672]]],
            'type': 'Polygon'},
        'ingestion_date': '20180103',
        'key': 'c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT',
        'path': '178',
        'row': '119',
        'satellite': 'L8',
        'scene_id': 'LC08_L1GT_178119_20180103_20180103_01_RT',
        'sensor': 'C',
        'sun_azimuth': 93.74503077,
        'sun_elevation': 22.51092792,
        'thumbURL':
            'https://landsat-pds.s3.amazonaws.com/c1/L8/178/119/LC08_L1GT_178119_20180103_20180103_01_RT/LC08_L1GT_178119_20180103_20180103_01_RT_thumb_small.jpg'}

    assert search.get_l8_info(scene_id, full, s3) == expected
    get_object.assert_called_once()